kingkh1995 opened a new issue, #9377:
URL: https://github.com/apache/rocketmq/issues/9377

   ### Before Creating the Bug Report
   
   - [x] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   
   - [x] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/discussions)  of this 
repository and believe that this is not a duplicate.
   
   - [x] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   
   ### Runtime platform environment
   
   any
   
   ### RocketMQ version
   
   5.3.2
   
   ### JDK Version
   
   jdk8
   
   ### Describe the Bug
   
   when shutdown AsyncTraceDispatcher, traceExecutor is not shutdown 
gracefully. 
   if shutdown producer very quick before send any trace message, after 
AsyncTraceDispatcher shutdown,  AsyncDataSendTask will still execute, and 
topicPublishInfo of trace topic is null , but traceProducer is shutdown 
already, updateTopicRouteInfoFromNameServer will fail, then send trace message 
will fail.
   so traceExecutor  should shutdown gracefully to avoid this scene.
   `
   // AsyncTraceDispatcher
       @Override
       public void shutdown() {
           flush();
           this.traceExecutor.shutdown();
           if (isStarted.get()) {
               traceProducer.shutdown();
           }
           this.removeShutdownHook();
           stopped = true;
       }
   `
   
   
   my test code:
   `
   public static void main(String[] args) throws MQClientException, 
InterruptedException, MQBrokerException, RemotingException {
           DefaultMQProducer producer = new DefaultMQProducer(PRODUCER_GROUP, 
true, null);
           producer.setNamesrvAddr(DEFAULT_NAMESRVADDR);
           producer.start();
           for (int i = 0; i < 13; i++) {
               try {
                   Message msg = new Message(TOPIC, TAG, "OrderID188", "Hello 
world".getBytes(StandardCharsets.UTF_8));
                   SendResult sendResult = producer.send(msg);
                   System.out.printf("%s%n", sendResult);
               } catch (Exception e) {
                   e.printStackTrace();
               }
           }
           producer.shutdown();
       }
   `
   error log:
   `
    ERROR MQTraceSendThread_0_1 - send trace data failed, the traceData is 
Pub1745947498841DefaultRegionProducerGroupNameTopicTest240E047CD8C94BA6F55B9B60C7894D91132818B4AAC295A639570000TagAmain_0192.168.255.186:1091119360C0A8FFBA00002A9F0000000000034D4Ftrue
   java.lang.IllegalStateException: 
org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to 
null failed
        at 
org.apache.rocketmq.client.impl.factory.MQClientInstance.updateTopicRouteInfoFromNameServer(MQClientInstance.java:859)
        at 
org.apache.rocketmq.client.impl.factory.MQClientInstance.updateTopicRouteInfoFromNameServer(MQClientInstance.java:576)
        at 
org.apache.rocketmq.client.trace.AsyncTraceDispatcher$AsyncDataSendTask.tryGetMessageQueueBrokerSet(AsyncTraceDispatcher.java:414)
        at 
org.apache.rocketmq.client.trace.AsyncTraceDispatcher$AsyncDataSendTask.sendTraceDataByMQ(AsyncTraceDispatcher.java:368)
        at 
org.apache.rocketmq.client.trace.AsyncTraceDispatcher$AsyncDataSendTask.flushData(AsyncTraceDispatcher.java:351)
        at 
org.apache.rocketmq.client.trace.AsyncTraceDispatcher$AsyncDataSendTask.sendTraceData(AsyncTraceDispatcher.java:328)
        at 
org.apache.rocketmq.client.trace.AsyncTraceDispatcher$AsyncDataSendTask.run(AsyncTraceDispatcher.java:299)
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750)
   Caused by: org.apache.rocketmq.remoting.exception.RemotingConnectException: 
connect to null failed
        at 
org.apache.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:584)
        at 
org.apache.rocketmq.client.impl.MQClientAPIImpl.getTopicRouteInfoFromNameServer(MQClientAPIImpl.java:2090)
        at 
org.apache.rocketmq.client.impl.MQClientAPIImpl.getTopicRouteInfoFromNameServer(MQClientAPIImpl.java:2081)
        at 
org.apache.rocketmq.client.impl.factory.MQClientInstance.updateTopicRouteInfoFromNameServer(MQClientInstance.java:798)
        ... 11 common frames omitted
   `
   
   
   
   ### Steps to Reproduce
   
   1. create a DefaultMQProducer and set traceEnable true;
   2. send one message
   3. shutdown producer immediately
   
   ### What Did You Expect to See?
   
   trace data send succeeded
   
   ### What Did You See Instead?
   
   trace data send failed
   
   ### Additional Context
   
   _No response_


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to