You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "Eppiehu (via GitHub)" <gi...@apache.org> on 2026/10/13 10:52:00 UTC

[I] [Bug] mqadmin consumeMessage consumes its message limit too early across queues [rocketmq]

Eppiehu opened a new issue, #11415:
URL: https://github.com/apache/rocketmq/issues/11415

   ### Before Creating the Bug Report
   
   - [x] I found a bug in this repository rather than a support question.
   - [x] I searched existing Issues and PRs and did not find the same fix.
   - [x] I confirmed that this issue belongs to apache/rocketmq.
   
   ### Runtime platform environment
   
   Windows 11, PowerShell, Maven 3.9.16.
   
   ### RocketMQ version
   
   5.5.1, develop. The affected production file was checked against the current official develop branch.
   
   ### JDK Version
   
   Eclipse Temurin OpenJDK 17.0.19.
   
   ### Describe the Bug
   
   [`ConsumeMessageCommand.executeDefault`](https://github.com/apache/rocketmq/blob/develop/tools/src/main/java/org/apache/rocketmq/tools/command/message/ConsumeMessageCommand.java#L270) subtracts `maxOffset - minOffset + 1` from the remaining `-c` message limit for each queue. The extra subtraction can exhaust the limit before the command visits another queue containing messages.
   
   A queue with `minOffset == maxOffset` also consumes one unit of the limit despite containing no messages.
   
   ### Steps to Reproduce
   
   Use a mocked `DefaultMQPullConsumer` and a `LinkedHashSet` containing two queues in deterministic order:
   
   1. Set `minOffset=0` and `maxOffset=1` for each queue and return one message from each.
   2. Execute `consumeMessage` with the arguments `{"-t", "mytopic", "-c", "2"}`.
   3. Count the printed messages.
   
   After the first queue, the code calculates `countLeft = 2 - (1 - 0) - 1 = 0`. The command then skips the second queue. The regression test fails with 2 expected messages versus 1 actual message.
   
   Another boundary case is an empty first queue followed by a one-message queue with `-c 1`: the empty queue exhausts the limit and the non-empty queue is skipped.
   
   ### What Did You Expect to See?
   
   With two one-message queues and `-c 2`, both messages should be printed. A queue whose minimum and maximum offsets are equal should not consume the remaining message limit.
   
   ### What Did You See Instead?
   
   Only the first message is printed in the two-queue case, even though another message is available.
   
   ### Additional Context
   
   The available offset range is `maxOffset - minOffset`; the extra `-1` in the remaining-limit calculation is unnecessary. I have prepared a one-line fix and deterministic mocked-consumer tests for empty queues, limits spanning queues, and stopping at the requested limit. The tests do not require a running cluster.
   


-- 
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: commits-unsubscribe@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] mqadmin consumeMessage consumes its message limit too early across queues [rocketmq]

Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin closed issue #11415: [Bug] mqadmin consumeMessage consumes its message limit too early across queues
URL: https://github.com/apache/rocketmq/issues/11415


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] mqadmin consumeMessage consumes its message limit too early across queues [rocketmq]

Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on issue #11415:
URL: https://github.com/apache/rocketmq/issues/11415#issuecomment-6145143517

   **Issue Evaluation**
   
   Category: `type/bug` | Status: **Confirmed**
   
   The reported issue has been verified against the current codebase.
   
   **Root Cause:** In `ConsumeMessageCommand.executeDefault()` line 270, the else branch decrements `countLeft` by `(maxOffset - minOffset) + 1` instead of `(maxOffset - minOffset)`. The extra `-1` causes the remaining quota to be consumed one message too early per queue.
   
   **Impact:** When consuming across multiple queues with `-c` limit, the tool delivers fewer messages than requested.
   
   **Severity:** Medium — correctness issue in admin tooling.
   
   The proposed fix (removing the `- 1` from the else branch) is correct. Looking forward to the PR.
   
   ---
   *Automated evaluation by RockteMQ-AI*


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org