Skip to content

[ISSUE #11572] fix(tools): bound mqadmin consumeMessage pull batch size - #11573

Open
frotmo wants to merge 1 commit into
apache:developfrom
frotmo:fix/consume-message-bounded-pull
Open

frotmo wants to merge 1 commit into
apache:developfrom
frotmo:fix/consume-message-bounded-pull

Conversation

@frotmo

@frotmo frotmo commented Nov 23, 2026

Copy link
Copy Markdown

Fixes #11572

Brief Description

mqadmin consumeMessage used (int) (maxOffset - offset + 1) as the
pull batch size. For a queue with more than Integer.MAX_VALUE
remaining messages, this wrapped to a non-positive maxNums;
DefaultMQPullConsumerImpl rejects maxNums <= 0 and the queue stops.

This change pulls in bounded batches of 32, the same size used by
PrintMessageByQueueCommand / PrintMessageSubCommand and aligned with
the broker's in-memory/disk batch limits, while keeping the -c total
semantics unchanged.

I deliberately did not claim a long overflow at
maxOffset = minOffset + countLeft - 1: that branch is guarded by
countLeft < maxOffset - minOffset, so it cannot overflow. The issue is
only the int cast at the pull call.

How Did You Test This Change?

  • mvn -pl tools -Dtest=ConsumeMessageCommandTest test
    • 10 tests passed.
  • mvn -pl tools test
    • 179 tests, 0 failures, 5 skipped.
  • Added testExecuteDefaultWithLargeQueueUsesBoundedPullBatch:
    • queue maxOffset = 3_000_000_000, -c = 3000000000;
    • captures the requested pull batch and asserts it is 32;
    • before the fix the same test captured -1294967295.

@frotmo

frotmo commented Nov 23, 2026

Copy link
Copy Markdown
Author

For reviewers: this is independent of #11415/#11416. #11416 changed the
countLeft accounting at line 270; this PR only bounds the pull batch at
line 220. The existing #11416 tests still pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] mqadmin consumeMessage can compute a negative maxNums for queues above Integer.MAX_VALUE

1 participant