Drifter-yh opened a new pull request, #11597: URL: https://github.com/apache/rocketmq/pull/11597
<!-- 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 delay between failed escape attempts (broker with `enableSlaveActingMaster`) was computed as `Thread.sleep(100L * (2 ^ escapeFailCnt))`. In Java `^` is XOR, not exponentiation, so for `escapeFailCnt` = 1..10 this slept `300, 0, 100, 600, 700, 400, 500, 1000, 1100, 800` ms: non-monotonic, and the second consecutive failure slept **0 ms**, so the check loop immediately re-put the message instead of backing off. This PR computes the delay as `100L * (1L << escapeFailCnt)` in a small package-private helper and uses it at the call site, restoring the intended exponential backoff `200, 400, 800, ..., 102400` ms. The retry counter, the give-up path and every other behavior stay unchanged. ### How Did You Test This Change? - Evaluated both expressions on JDK 17 (`jshell`): before `100L * (2 ^ n)` → `300 0 100 600 700 400 500 1000 1100 800` ms; after `100L * (1L << n)` → `200 400 800 1600 3200 6400 12800 25600 51200 102400` ms. - Added `TransactionalMessageServiceImplTest#testEscapeRetryBackoffMillisIsExponential`, which checks the exponential progression for retry counts 1..10, verifies the delays are strictly increasing, and explicitly rejects the old 0 ms second retry. - `mvn -pl broker -am -Dtest=TransactionalMessageServiceImplTest test` on Windows 11, Microsoft OpenJDK 17.0.14 and Maven 3.9.2 → `Tests run: 9, Failures: 0, Errors: 0, Skipped: 0` (8 pre-existing + 1 new). - `mvn -pl broker -am -DskipTests validate` → `You have 0 Checkstyle violations.` - `git diff --check` passed. ### Risk Low: only the sleep duration on the escape-failure path changes, from the accidental XOR sequence to the intended exponential one (200 ms doubling up to 102.4 s at the 10th consecutive failure, still bounded by `MAX_RETRY_TIMES_FOR_ESCAPE`). No API, data format or retry-count change. AI assistance: analysis, implementation and verification were assisted by AI tooling; the result was reviewed before submission. -- 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]
