lollipopjin commented on code in PR #8430:
URL: https://github.com/apache/rocketmq/pull/8430#discussion_r1687520954


##########
client/src/main/java/org/apache/rocketmq/client/trace/AsyncTraceDispatcher.java:
##########
@@ -197,26 +198,14 @@ public boolean append(final Object ctx) {
 
     @Override
     public void flush() {
-        // The maximum waiting time for refresh,avoid being written all the 
time, resulting in failure to return.
         long end = System.currentTimeMillis() + 500;
-        while (System.currentTimeMillis() <= end) {
-            synchronized (taskQueueByTopic) {
-                for (TraceDataSegment taskInfo : taskQueueByTopic.values()) {
-                    taskInfo.sendAllData();
-                }
-            }
-            synchronized (traceContextQueue) {
-                if (traceContextQueue.size() == 0 && appenderQueue.size() == 
0) {
-                    break;
-                }
-            }
+        while (traceContextQueue.size() > 0 || appenderQueue.size() > 0 && 
System.currentTimeMillis() <= end) {
             try {
-                Thread.sleep(1);
-            } catch (InterruptedException e) {
-                break;
+                flushTraceContext();
+            } catch (Throwable e) {
             }
         }
-        log.info("------end trace send " + traceContextQueue.size() + "   " + 
appenderQueue.size());
+        log.warn("There are still some traces that haven't been sent " + 
traceContextQueue.size() + "   " + appenderQueue.size());

Review Comment:
   no need to print warn log here if  traceContextQueue's size is 0.



-- 
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: commits-unsubscr...@rocketmq.apache.org

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

Reply via email to