You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "teamoTNT (via GitHub)" <gi...@apache.org> on 2023/04/23 08:14:22 UTC

[GitHub] [skywalking] teamoTNT opened a new issue, #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

teamoTNT opened a new issue, #10722:
URL: https://github.com/apache/skywalking/issues/10722

   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### Apache SkyWalking Component
   
   Java Agent (apache/skywalking-java)
   
   ### What happened
   
   When project  use old version cloud-stream-rocketmq-starter, it will causes memory leaks.
   ps: Higher versions do not have this problem
   
          <dependency>
               <groupId>com.alibaba.cloud</groupId>
               <artifactId>cloud-stream-rocketmq-starter</artifactId>
               <version>1.3.2</version>
           </dependency>
   
   
   
   **Issue source code** 
   (MessageConcurrentlyConsumeInterceptor and MessageOrderlyConsumeInterceptor):
   
       @Override
       public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
           Object ret) throws Throwable {
   
           ConsumeOrderlyStatus status = (ConsumeOrderlyStatus) ret;
           if (status == ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT) {
               AbstractSpan activeSpan = ContextManager.activeSpan();
               activeSpan.errorOccurred();
               Tags.MQ_STATUS.set(activeSpan, status.name());
           }
           ContextManager.stopSpan();
           return ret;
       }
   
   **cause**
   cloud-stream-rocketmq-starter encapsulation the method of messageListener.
   
       protected class CloudStreamMessageListenerConcurrently extends RocketMQInboundChannelAdapter.CloudStreamMessageListener implements MessageListenerConcurrently {
           public ConsumeConcurrentlyStatus consumeMessage(final List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
               Acknowledgement acknowledgement = this.consumeMessage(msgs);
               context.setDelayLevelWhenNextConsume(acknowledgement.getConsumeConcurrentlyDelayLevel());
               return acknowledgement.getConsumeConcurrentlyStatus();
           }
       }
   
   The interceptor to be triggered twice and an exception has occurred (java.lang.ClassCastException).  
   ![image](https://user-images.githubusercontent.com/103160892/233827261-b6c01bce-60ef-4af5-b7ed-c1ee931eb4d7.png)
   ![image](https://user-images.githubusercontent.com/103160892/233827265-90334865-87ff-4fad-85dd-481b049c62d4.png)
   
   In addition, the MQ consumer get thread  from thread  pool. That the span can not stop, the class are alse not gc.
   ![image](https://user-images.githubusercontent.com/103160892/233827751-9847546b-a0dc-422c-817c-d72e9febbe49.png)
   
   
   
   ### What you expected to happen
   
   Although it's an issue with older versions, I think the robustness of the code can be enhanced.
   
   Add type judgment in interceptor (MessageConcurrentlyConsumeInterceptor and MessageOrderlyConsumeInterceptor)
   like:
   
   
       public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,Object ret) throws Throwable {
           if (ret instanceof ConsumeConcurrentlyStatus) {
               ConsumeConcurrentlyStatus status = (ConsumeConcurrentlyStatus) ret;
               if (status == ConsumeConcurrentlyStatus.RECONSUME_LATER) {
                   AbstractSpan activeSpan = ContextManager.activeSpan();
                   activeSpan.errorOccurred();
                   Tags.MQ_STATUS.set(activeSpan, status.name());
               }
           }
           ContextManager.stopSpan();
           return ret;
       }
   
   
   ### How to reproduce
   
   user old version cloud-stream-rocketmq-starter
   
          <dependency>
               <groupId>com.alibaba.cloud</groupId>
               <artifactId>cloud-stream-rocketmq-starter</artifactId>
               <version>1.3.2</version>
           </dependency>
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] lujiajing1126 commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "lujiajing1126 (via GitHub)" <gi...@apache.org>.
lujiajing1126 commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1519030190

   > > So, what exactly happens? I am not following now. Once `create` and `stop` execute twice, it should be fine.
   > 
   > two `create` and one `stop`! It missing one `stop` due to an ClassCastException.
   
   This is not the root cause.
   
   This method https://github.com/alibaba/spring-cloud-alibaba/blob/b28e82dc3cf0d534dc98e78294412d2f05e11b8f/spring-cloud-stream-binder-rocketmq/src/main/java/org/springframework/cloud/stream/binder/rocketmq/integration/RocketMQInboundChannelAdapter.java#L170 is unexpectedly intercepted due to the incomplete method matcher in the definition if you check the comment,
   
   https://github.com/apache/skywalking-java/blob/02dad132b2807cbecdb69c7c0fbce54d36bd6e3e/apm-sniffer/apm-sdk-plugin/rocketMQ-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/rocketMQ/v4/MessageConcurrentlyConsumeInterceptor.java#L28-L32


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] wu-sheng commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1519012263

   So, what exactly happens? I am not following now. Once `create` and `stop` execute twice, it should be fine.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] wu-sheng commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1518991188

   Feel free to open the pull request. We could discuss the details there.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] wu-sheng commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1519017881

   So, the type was different the some old versions only?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] wu-sheng commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1518993128

   One question would be, if this `afterMethod` is invoked twice,  why the `beforeMethod` doesn't?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] teamoTNT commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "teamoTNT (via GitHub)" <gi...@apache.org>.
teamoTNT commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1519036709

   I don't think it's going to be changed, it's my own problem. 
   I will close this issue. 
   Thank you very much.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] teamoTNT commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "teamoTNT (via GitHub)" <gi...@apache.org>.
teamoTNT commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1519018758

   Yep


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] teamoTNT commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "teamoTNT (via GitHub)" <gi...@apache.org>.
teamoTNT commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1519005667

   > One question would be, if this is invoked twice, why the doesn't?`afterMethod``beforeMethod`
   
   `beforeMethod` also invoked twice. This means that `ContextManager.createEntrySpan()` was executed twice  that it need execute the stopSpan-method twice too(`ContextManager.stopSpan()`);


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] wu-sheng commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1519033088

   The only concern is, this is an old release, and dead version series.
   
   Apr 19, 2019 is the last release date.
   
   Meanwhile, instanceof operation costs resources. Is that worth all users to pay?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] teamoTNT closed issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "teamoTNT (via GitHub)" <gi...@apache.org>.
teamoTNT closed issue #10722: [Bug]  rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter
URL: https://github.com/apache/skywalking/issues/10722


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] wu-sheng commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1519019779

   I can't find 1.3.2 from maven central, https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-stream-rocketmq . The 2.0 was from 3 years ago.
   How did you get this? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] teamoTNT commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "teamoTNT (via GitHub)" <gi...@apache.org>.
teamoTNT commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1519017161

   > So, what exactly happens? I am not following now. Once `create` and `stop` execute twice, it should be fine.
   
   two `create` and one  `stop`!
   It missing one  `stop` due to an ClassCastException.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] teamoTNT commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "teamoTNT (via GitHub)" <gi...@apache.org>.
teamoTNT commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1519022899

   > I can't find 1.3.2 from maven central, https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-stream-rocketmq . The 2.0 was from 3 years ago. How did you get this?
   
   Sorry, I wrote the groupId incorrectly.
   https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-stream/1.3.2.RELEASE
   `org.springframework.cloud.stream.binder.rocketmq.integration.RocketMQInboundChannelAdapter.CloudStreamMessageListenerConcurrently`
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking] lujiajing1126 commented on issue #10722: [Bug] rocketMQ-4.x-plugin causes memory leaks when project user old version cloud-stream-rocketmq-starter

Posted by "lujiajing1126 (via GitHub)" <gi...@apache.org>.
lujiajing1126 commented on issue #10722:
URL: https://github.com/apache/skywalking/issues/10722#issuecomment-1519026919

   > Sorry, I wrote the groupId incorrectly. https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-stream/1.3.2.RELEASE `org.springframework.cloud.stream.binder.rocketmq.integration.RocketMQInboundChannelAdapter.CloudStreamMessageListenerConcurrently`
   
   But where does `CloudStreamMessageListenerConcurrently` locate? I don't think it is related to the `spring-cloud-stream`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org