RockteMQ-AI commented on issue #10966: URL: https://github.com/apache/rocketmq/issues/10966#issuecomment-5422445800
**Issue Evaluation** Category: `type/bug` | Status: **Confirmed** The reported busy-loop in `TransactionalOpBatchService` has been verified against the source code. **Root Cause Analysis:** 1. `deleteContext` (a `ConcurrentHashMap` in `TransactionalMessageServiceImpl`) accumulates entries via `deletePrepareMessage()` but **entries are never removed** — even after all offsets in a `MessageQueueOpContext` have been batched and sent. 2. In `batchSendOpMessage()` (line ~706), the loop iterates over all `deleteContext` entries. For entries where `totalSize <= 0` or `contextQueue.size() == 0` (i.e., already drained), the code still updates `firstTimestamp = Math.min(firstTimestamp, mqContext.getLastWriteTimestamp())` and then `continue`s. 3. When all contexts are empty, `firstTimestamp` reflects a stale (old) write timestamp. The computed `wakeupTimestamp = firstTimestamp + interval` falls **before** `startTime`, so the guard `wakeupTimestamp > startTime` fails. 4. The method falls through to `return 0L`. 5. Back in `TransactionalOpBatchService.run()`, `onWaitEnd()` sets `wakeupTimestamp = 0`. On the next iteration, `interval = 0 - now < 0`, triggering `wakeup()` + `waitForRunning(0)` — **a tight busy loop consuming one full CPU core**. **Impact:** Any workload that sends transaction messages and then becomes idle will pin one CPU core at ~100% indefinitely. This matches the reported symptom exactly. **Severity:** High — causes persistent CPU waste in production after transaction message usage. **Suggested fix direction:** - When `batchSendOpMessage()` finds that all contexts are empty (no `sendMap` produced), return `System.currentTimeMillis() + interval` instead of `0L` to ensure a proper sleep. - Alternatively, consider pruning empty entries from `deleteContext` after their offsets have been flushed. An automated fix proposal can be generated. Reply `/approve` to proceed with PR generation. --- *Automated evaluation by github-manager-bot* -- 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]
