rundood5 commented on code in PR #11597:
URL: https://github.com/apache/rocketmq/pull/11597#discussion_r4676272680


##########
broker/src/main/java/org/apache/rocketmq/broker/transaction/queue/TransactionalMessageServiceImpl.java:
##########
@@ -250,7 +250,7 @@ public void check(long transactionTimeout, int 
transactionCheckMax,
                                     
msgExt.getUserProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX));
                                 if (escapeFailCnt < 
MAX_RETRY_TIMES_FOR_ESCAPE) {
                                     escapeFailCnt++;
-                                    Thread.sleep(100L * (2 ^ escapeFailCnt));
+                                    
Thread.sleep(escapeRetryBackoffMillis(escapeFailCnt));

Review Comment:
   The XOR observation is correct — I checked 
`TransactionalMessageServiceImpl#check` on develop and
   line 253 is indeed `Thread.sleep(100L * (2 ^ escapeFailCnt));`, so `^` is 
XOR and the second
   consecutive failure sleeps 0 ms. The fix direction looks right.
   
   One thing I'd like to understand before this goes in: with `1L << 
escapeFailCnt` and
   `MAX_RETRY_TIMES_FOR_ESCAPE = 10`, the last sleep is `100 * 2^10 = 102_400 
ms` (~102 s), and it
   happens inside the per-queue check loop. The loop only checks 
`MAX_PROCESS_TIME_LIMIT` at the top,
   so a queue that keeps failing to escape can now block the check thread for 
over a minute, where the
   accidental XOR kept the worst case around a second. If the check service 
processes queues on a
   bounded pool, other queues pay that delay too.
   
   Would it make sense to cap the backoff (a few seconds), or bound the sleep 
by the remaining time
   budget before `MAX_PROCESS_TIME_LIMIT`? Not blocking this PR — restoring the 
intended exponential
   shape is clearly better than the XOR sequence — but the 102 s tail is a 
behaviour change worth
   deciding on explicitly.



-- 
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