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

   **Fix Spec — Issue #11433**
   
   A fix proposal has been generated based on code analysis.
   
   **Root Cause (2 races verified):**
   
   1. **Race with `cleanUnusedResource()`:** In `polling()`, between 
`pollingMap.get()` (line 218) and `queue.add()` (line 233), the cleanup thread 
can remove the empty queue entry. The request is added to an orphaned queue 
that no wake path can find.
   
   2. **Capacity eviction:** When `pollingMap` reaches capacity, the LRU 
eviction silently drops entire queues. No eviction listener is registered, so 
affected requests are never woken.
   
   **Proposed Fix:**
   
   1. In `polling()`: after successful `queue.add()`, re-check that the queue 
is still in `pollingMap`. If evicted, immediately wake the request.
   2. Register an `EvictionListener` on the `ConcurrentLinkedHashMap` builder 
to wake all requests in evicted queues.
   3. In `cleanUnusedResource()`: before removing an empty queue, verify no 
in-flight `polling()` call is about to add to it (or adopt the classic 
`PopLongPollingService` pattern of checking topic/group meta).
   
   **Scope:** Changes to `PopLiteLongPollingService.java` only. The classic 
`PopLongPollingService` does not have this race and serves as a reference 
pattern.
   
   Reply `/approve` to proceed with PR generation, `/revise <feedback>` to 
request changes, or `/reject` to decline.
   
   ---
   *Automated fix proposal by RockteMQ-AI*


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