Felix-Gong opened a new issue, #11481:
URL: https://github.com/apache/rocketmq/issues/11481

   ### Search before asking
   
   I checked open and closed issues and PRs for 
`TopicQueueMappingCleanService`, queue-mapping cleanup and static-topic null 
handling. #8728 (closed) asked for more unit tests on this service and is 
resolved; #8752 is an unrelated crash report. No open issue or PR covers a 
failed clean pass, and no open PR currently touches 
`TopicQueueMappingCleanService.java`.
   
   ### What happened?
   
   `TopicQueueMappingCleanService.cleanItemListMoreThanSecondGen()` reconciles 
queue mappings after a leader move: for every queue whose leader moved away, it 
fetches the new leader's mapping and confirms the new leader really owns that 
queue. The check is:
   
   ```java
   List<LogicQueueMappingItem> items = 
remoteMappingDetail.getHostedQueues().get(qId);
   if (items.isEmpty()) {
       continue;
   }
   ```
   
   `getHostedQueues()` is a map, so when the remote broker's mapping has **no 
entry at all** for this queue id, `get(qId)` returns `null` and 
`items.isEmpty()` throws `NullPointerException`.
   
   That "no entry" state is not hypothetical — it is precisely the transient 
inconsistency this service exists to reconcile (a mapping update that has not 
propagated to the new leader yet, or a leader that never hosted that queue). 
The NPE is caught by the per-topic `catch (Throwable)`, so the damage is silent:
   
   - the current clean pass for that topic stops at the first such queue,
   - every **remaining** queue of the same topic is skipped for this cycle 
(queues that would otherwise have been cleaned are not),
   - the same failure repeats on the next 5-minute cycle, logging an error each 
time.
   
   So one unpropagated queue can keep a whole topic's stale mapping entries 
alive indefinitely.
   
   ### Expected behavior
   
   A remote mapping that does not contain the queue id should be treated like 
the other "not confirmed yet" cases nearby (`continue`), not crash the pass. 
The remaining queues of the topic must still be evaluated and cleaned in the 
same cycle.
   
   ### Runtime
   
   develop at 57c2dc0, JDK 11. Reproduced against the existing 
`TopicQueueMappingCleanServiceTest` fixtures: a topic with two moved queues 
where the new leader's mapping omits one of them. With the current code the 
second queue is never removed; with a null guard it is removed in the same pass.
   


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