[Bug] Bare lock busy-wait without yield in ack/changeInvisibleTime processors pins ack executor threads

オープン
#11,383 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@messere1 がすでに取り組んでいます。

2026年10月12日 から。

  • #11384 @messere1 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
java

調査の方向性

Read the listed lock loops in AckMessageProcessor.java and ChangeInvisibleTimeProcessor.java, then compare them with PopConsumerService#tryLockForPop and the ackMessageExecutor registration in BrokerController.java. Check the linked pull request #11384 for current work. Done means the listed contended paths yield while preserving their lock behavior.

索引モデルが issue の本文から書いたものです。

説明

Before Creating the Bug Report
  • I found a bug. The issue list contains no issue matching my bug.
Your Environment
  • RocketMQ version: 5.4.x (current develop)
Describe the Bug

Several pop/ack paths acquire the consumer/queue lock with a bare busy-wait that has no Thread.yield():

  • AckMessageProcessor#ackOrderly — while (!queueLockManager.tryLock(lockKey)) {} (broker/src/main/java/org/apache/rocketmq/broker/processor/AckMessageProcessor.java:405)
  • AckMessageProcessor#ackOrderly (KV service path) — while (!consumerLockService.tryLock(consumeGroup, topic)) {} (AckMessageProcessor.java:448)
  • AckMessageProcessor#ackLite — while (!consumerLockService.tryLock(lockKey)) {} (AckMessageProcessor.java:538)
  • ChangeInvisibleTimeProcessor#changeInvisibilityDuration — same shape (ChangeInvisibleTimeProcessor.java:203, :235, :389)

All of these are registered on the shared ackMessageExecutor (BrokerController.java:1204-1213), so each contending request pins one worker thread at 100% CPU for the entire contention window:

  1. Under a (group, topic) contention burst, several executor workers can be stuck spinning at once, cutting the executor's effective parallelism for every other ack / changeInvisibleTime request on the broker.
  2. On core-saturated brokers the spinning threads compete for CPU with the very lock holders that must finish for the spin to exit, extending the wait beyond the actual critical-section length.

The codebase already establishes the correct pattern for this lock service: PopConsumerService#tryLockForPop (added by #10828) spins with Thread.yield() and a comment explaining why the spin is kept — same consumerLockService, same contention shape, but it yields.

Steps to Reproduce

Code inspection + any workload where two consumers of the same group ack/changeInvisibleTime concurrently for the same topic: the losing request's thread spins in the while loop with no yield until the holder releases (or PopConsumerLockService.removeTimeout() self-heals a stale entry).

What Did You Expect to See?

The spin semantics preserved (these paths must hold the lock to commit offsets atomically) but with Thread.yield() in the loop, matching tryLockForPop — so a contending worker yields its core to the holder instead of burning it.

Additional Context

None

主要言語
Java
スター
22.7k
フォーク
12k
平均マージ
4日 20時間
マージ済み PR(30日)
11

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/rocketmq のほかの issue

apache/rocketmq の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。