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

   **Issue Evaluation**
   
   Category: `type/bug` | Status: **Confirmed**
   
   The reported issue has been verified against the current codebase at 
`a06836d`.
   
   **Root Cause:** `PopMessageProcessor.cleanUnusedLock()` iterates 
`expiredLocalCache` and removes entries where `currentTime - lockTime > 
usedExpireMillis` without checking `isLock()`. Since `tryLock()` updates 
`lockTime` on the same `TimedLock` object (via CAS), the cleanup can remove a 
freshly reacquired lock if it reads the stale `lockTime` in the narrow window 
before `tryLock()` updates it. The Javadoc on `cleanUnusedLock` explicitly 
acknowledges: *"is not thread safe, may cause duplicate lock"*.
   
   **Impact:** A removed lock allows concurrent POP processing for the same 
queue — defeating the lock's purpose. Subsequent `unLock` calls get null or the 
wrong `TimedLock`, leaving the original lock improperly released.
   
   **Severity:** High — concurrent POP processing for the same queue can cause 
duplicate message delivery or ordering violations.
   
   **Suggested fix direction:** Add an `isLock()` check before 
`iterator.remove()`, and consider using a thread-safe concurrent map with 
atomic remove-if-matches semantics.
   
   An automated fix proposal can be generated. Reply `/approve` to proceed with 
PR generation.
   
   ---
   *Automated evaluation 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