Before Creating the Bug Report
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.
`
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 Pub�1745947498841�DefaultRegion�ProducerGroupName�TopicTest�240E047CD8C94BA6F55B9B60C7894D91132818B4AAC295A639570000�TagA�main_0�192.168.255.186:10911�1�936�0�C0A8FFBA00002A9F0000000000034D4F�true�
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
- create a DefaultMQProducer and set traceEnable true;
- send one message
- 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
Before Creating the Bug Report
I found a bug, not just asking a question, which should be created in GitHub Discussions.
I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.
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.
`
`
my test code:
`
public static void main(String[] args) throws MQClientException, InterruptedException, MQBrokerException, RemotingException {
`
error log:
ERROR MQTraceSendThread_0_1 - send trace data failed, the traceData is Pub�1745947498841�DefaultRegion�ProducerGroupName�TopicTest�240E047CD8C94BA6F55B9B60C7894D91132818B4AAC295A639570000�TagA�main_0�192.168.255.186:10911�1�936�0�C0A8FFBA00002A9F0000000000034D4F�true�
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
What Did You Expect to See?
trace data send succeeded
What Did You See Instead?
trace data send failed
Additional Context
No response