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

   ## 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 ids `4..7` -> `WRITE`
   - **Before fix:** queue ids `0..3` -> `WRITE`, queue ids `4..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_WRITE`
   - `id < writeQueueNums` only -> `WRITE`
   - `id < readQueueNums` only -> `READ`
   
   The write-only, read-only, and no-access branches remain unchanged.
   
   ## Test Plan
   
   - [x] Updated `RouteActivityTest#testGenPartitionFromQueueData` to verify 
the per-queue-id permission mapping for `readQueueNums = 4, writeQueueNums = 8` 
(ids `0..3` -> `READ_WRITE`, ids `4..7` -> `WRITE`)
   - [x] Added test case for `readQueueNums = 8, writeQueueNums = 4` (ids 
`0..3` -> `READ_WRITE`, ids `4..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`)


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