fix(message): enumerate read queues when listing queue offsets - #3309
Open
zjncs wants to merge 1 commit into
Open
fix(message): enumerate read queues when listing queue offsets#3309zjncs wants to merge 1 commit into
zjncs wants to merge 1 commit into
Conversation
getQueueOffsets iterated queueData.getWriteQueueNums() while every other browse path is read-queue based: the broker's PullMessageProcessor rejects queueId >= readQueueNums with SYSTEM_ERROR, and fetchSubscribeMessageQueues (used by queryByTopic and the classic console) enumerates [0, readQueueNums). When read != write: - read > write (shrink draining): queues in [write, read) still hold browsable messages but were missing from the QueueBrowser - write > read (queues not yet readable): queues in [read, write) were listed but every pull on them fails with "queueId is illegal" Enumerate from readQueueNums to match the broker's pull validation.
zjncs
marked this pull request as ready for review
September 5, 2026 09:29
RockteMQ-AI
approved these changes
Sep 5, 2026
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Correct fix — getQueueOffsets should enumerate read queues, not write queues:
- Consumers read from read queues
- Broker rejects pull requests for
queueId >= readQueueNumswith SYSTEM_ERROR - When
writeQueueNums > readQueueNums, old code listed non-browsable queues - When
readQueueNums > writeQueueNums(queue shrinking), old code missed queues with messages
Tests validate both scenarios (read > write and write > read).
LGTM.
Automated review by github-manager-bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
RocketMQMessageProvider.getQueueOffsetslists the Queue Browser's queues withqueueData.getWriteQueueNums(), but every other message-browse path is read-queue based:PullMessageProcessorrejects any pull withqueueId >= topicConfig.getReadQueueNums()(SYSTEM_ERROR"queueId is illegal");fetchSubscribeMessageQueues— used by this provider's ownqueryByTopicand by the classic console'squeryMessageByTopic— enumerates[0, readQueueNums).So whenever a topic has
readQueueNums != writeQueueNums(the standard expansion/shrink procedure sets the two counts independently, e.g.updateTopic -r 16 -w 8), the Queue Browser is wrong:[write, read)are still readable and still hold messages, but they never appear in the browser — the user cannot browse them at all, and the queue list disagrees with whatqueryByTopicscans.[read, write)are listed, but each one is a dead end — pulling from it fails with "queueId is illegal".The
writeQueueNumsiteration was introduced incidentally by the admin-client pooling refactor b5a7d6c (#2544), not as a deliberate queue-selection choice.Fix
Enumerate
[0, queueData.getReadQueueNums())ingetQueueOffsets, matching the broker's pull validation and the read-queue enumeration used by the other browse paths. One-line change.Verification
Base SHA: 3612602 (rocketmq-studio)
Fail-before / pass-after on the two new tests in
RocketMQMessageProviderTest:getQueueOffsetsListsReadQueuesWhenReadCountExceedsWriteCount(read=4, write=2): failed with[0, 1]vs expected[0, 1, 2, 3]; passes after the fix (also asserts min/max offsets are wired per queue).getQueueOffsetsSkipsWriteOnlyQueuesWhenWriteCountExceedsReadCount(read=2, write=4): failed with[0, 1, 2, 3]vs expected[0, 1]; passes after the fix.Full run after the fix:
RocketMQMessageProviderTest: 38/38 pass (36 pre-existing + 2 new)org.apache.rocketmq.studio.provider.apachepackage: 256/256 passAI disclosure: This change was prepared with AI assistance (GitHub Copilot/Claude-style tooling guided by a human contributor).