frotmo opened a new pull request, #11573:
URL: https://github.com/apache/rocketmq/pull/11573

   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`.


-- 
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]

Reply via email to