RocketMQ 5.5.0 的事务消息批处理线程陷入忙循环,CPU 10%
- Dominant language
- Java
- Stars
- 22.6k
- Forks
- 12k
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 27
Description
### Before Creating the Bug Report
- [x] I found a bug, not just asking a question, which should be created in [GitHub Discussions](https://github.com/apache/rocketmq/discussions).
- [x] I have searched the [GitHub Issues](https://github.com/apache/rocketmq/issues) and [GitHub Discussions](https://github.com/apache/rocketmq/discussions) of this repository and believe that this is not a duplicate.
- [x] I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.
### Runtime platform environment
macos 15.1 M4
### RocketMQ version
5.5.0 docker
### JDK Version
21
### Describe the Bug
RocketMQ 5.5.0 的事务消息批处理线程陷入忙循环.
实时证据:
- Broker 内线程 TransactionalOpBatchService(Linux TID 197)稳定占用 99.9% 单核。
- 连续线程栈固定在:
TransactionalMessageServiceImpl.batchSendOpMessage() 第 706 行遍历 deleteContext。
- Lite 端测发送事务消息后会100%触发该路径;事务 half/op topic 均只有 14 条且 offset 已对齐,排除了积压和事务回查负
载。
目前认为的根因是 RocketMQ 5.5.0 的实现缺陷:事务操作上下文已清空后仍保留在 deleteContext 中;batchSendOpMessage()
对过期空上下文返回 0,而 TransactionalOpBatchService 将其视为“立刻再次执行”,于是无休眠反复遍历该 Map,打满一个
CPU 核。源码逻辑可见:TransactionalOpBatchService
(https://github.com/apache/rocketmq/blob/rocketmq-all-5.5.0/broker/src/main/java/org/apache/rocketmq/broker/transaction/queue/TransactionalOpBatchService.java)
与 TransactionalMessageServiceImpl
(https://github.com/apache/rocketmq/blob/rocketmq-all-5.5.0/broker/src/main/java/org/apache/rocketmq/broker/transaction/queue/TransactionalMessageServiceImpl.java)。
### Steps to Reproduce
Lite 端测发送事务消息后会100%触发该路径
### What Did You Expect to See?
本地cluster 模式,Lite 端测发送事务消息,100%触发
### What Did You See Instead?
CPU 100%
### Additional Context
_No response_
Contributor guide
Research direction
Start with broker/src/main/java/org/apache/rocketmq/broker/transaction/queue/TransactionalOpBatchService.java and TransactionalMessageServiceImpl.java, especially batchSendOpMessage() around line 706. Reproduce with the Lite transactional-message test in a local cluster, inspect deleteContext and the batch-service loop, and confirm the TransactionalOpBatchService no longer drives a busy loop after the transaction context is cleared.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100