unbridled-41 opened a new pull request, #10993:
URL: https://github.com/apache/rocketmq/pull/10993

   <!-- Please make sure the target branch is right. In most case, the target 
branch should be `develop`. -->
   
   ### Which Issue(s) This PR Fixes
   
   - Fixes #10989
   
   ### Brief Description
   
   In `TransactionalMessageServiceImpl#check`, the retry delay between failed 
escape attempts (broker with `enableSlaveActingMaster`, `escapeMessage` 
failing) was computed as
   
   ```java
   Thread.sleep(100L * (2 ^ escapeFailCnt));
   ```
   
   In Java `^` is XOR, not exponentiation, so the actual sleep sequence for 
`escapeFailCnt` = 1..10 was `300, 0, 100, 600, 700, 400, 500, 800, 900, 200` ms 
— non-monotonic and including a **0 ms** delay on the second failure, which 
defeats the backoff entirely and hammers the store with immediate re-puts.
   
   This PR extracts the computation into a package-private helper 
`escapeRetryBackoffMillis(int)` that returns the intended exponential backoff 
`100L * (1 << escapeFailCnt)` (200, 400, 800, ... ms), and uses it at the call 
site. No behavior other than the delay values changes.
   
   ### How Did You Test This Change?
   
   Added 
`TransactionalMessageServiceImplTest#testEscapeRetryBackoffMillisIsExponential`,
 which asserts `escapeRetryBackoffMillis(i) == 100L * (1L << i)` for i = 1..10. 
It fails on the old code (XOR sequence) and passes with this change.
   
   `mvn -pl broker test -Dtest=TransactionalMessageServiceImplTest` passes 
(9/9).


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