RockteMQ-AI commented on issue #11441:
URL: https://github.com/apache/rocketmq/issues/11441#issuecomment-6169119324

   **Issue Evaluation**
   
   Category: `type/bug` | Status: **Confirmed**
   
   The reported issue has been verified against the current codebase on the 
`develop` branch.
   
   **Root Cause:**  
   `PullRequestHoldService.notifyMasterOnline()` iterates over the result of 
`ManyPullRequest.cloneListAndClear()` without checking for null. The 
`cloneListAndClear()` method returns `null` (not an empty list) when the bucket 
is empty at drain time. A race condition exists between the `isEmpty()` check 
and the `cloneListAndClear()` call: another thread (the store's dispatch thread 
via `notifyMessageArriving`) can drain the bucket in between, causing the 
enhanced for loop to throw `NullPointerException`.
   
   **Code Evidence:**  
   - `notifyMessageArriving()` properly guards with `if (requestList != null)` 
before iterating
   - `notifyMasterOnline()` lacks this guard, directly iterating: `for 
(PullRequest request : mpr.cloneListAndClear())`
   
   **Impact:**  
   - **High**: The NPE escapes into `onMinBrokerChange`, aborting the sweep. 
All unvisited buckets keep their requests suspended, causing clients to wait 
their full suspend timeout — exactly the stall this method exists to prevent, 
during the critical failover window.
   - The exception propagates to the min-broker update caller, causing spurious 
failures.
   
   **Severity:** High — affects broker failover reliability and long-polling 
wake-up correctness.
   
   **Proposed Fix:**  
   Add a null check in `notifyMasterOnline()` consistent with 
`notifyMessageArriving()`:
   ```java
   List<PullRequest> requestList = mpr.cloneListAndClear();
   if (requestList != null) {
       for (PullRequest request : requestList) {
           // ... existing logic
       }
   }
   ```
   
   An automated fix proposal will be generated. Reply `/approve` to proceed 
with PR generation.
   
   ---
   *Automated evaluation by github-manager-bot*
   


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