[ISSUE #10529] Fix incorrect queue permissions in gRPC QueryRouteResponse
What Changed
Fixed the permission assignment logic in RouteActivity#genMessageQueueFromQueueData so that each MessageQueue's permission is derived from its queue id rather than being assigned by grouped permission counts.
Why
When the gRPC proxy builds QueryRouteResponse, the old implementation calculated the number of read-only, write-only, and read-write queues first, then appended them in groups (READ, WRITE, READ_WRITE) while increasing the queue id. This preserved the count of each permission type but assigned the permission to the wrong queue id.
For example, with readQueueNums = 4, writeQueueNums = 8, and PERM_READ | PERM_WRITE:
- Expected: queue ids
0..3->READ_WRITE, queue ids4..7->WRITE - Before fix: queue ids
0..3->WRITE, queue ids4..7->READ_WRITE
Since MessageQueue.id is part of the queue identity, the permission must match the actual queue id. The internal route selection logic also builds read/write queues by iterating queue ids from 0 to readQueueNums - 1 or writeQueueNums - 1, confirming that the permission should be derived per queue id.
How
Instead of grouping by permission type, iterate queue ids from 0 to max(readQueueNums, writeQueueNums) - 1 and derive the permission per id:
id < readQueueNums && id < writeQueueNums->READ_WRITEid < writeQueueNumsonly ->WRITEid < readQueueNumsonly ->READ
The write-only, read-only, and no-access branches remain unchanged.
Test Plan
- [x] Updated
RouteActivityTest#testGenPartitionFromQueueDatato verify the per-queue-id permission mapping forreadQueueNums = 4, writeQueueNums = 8(ids0..3->READ_WRITE, ids4..7->WRITE) - [x] Added test case for
readQueueNums = 8, writeQueueNums = 4(ids0..3->READ_WRITE, ids4..7->READ) - [x] All existing test cases (equal read/write, read-only, write-only, no-access) continue to pass
- [ ] CI passes (
maven-compile,license-checker)