Eppiehu commented on PR #11592:
URL: https://github.com/apache/rocketmq/pull/11592#issuecomment-7120533256

   Thanks for the fix, LGTM on the core change. I read it against 
`ProcessQueue` on develop:
   
   1. `queueOffsetMax` is only written in `putMessage` / `clear()` and only 
read in `removeMessage` (`queueOffsetMax + 1` when the tree map drains), so 
switching to `Math.max` is enough and has no side effect on other callers. The 
write happens under `treeMapLock.writeLock()`, so the read-compare-write is 
safe.
   
   2. A related spot in the same method still assumes the last message of the 
batch has the highest offset:
   
      ```java
      MessageExt messageExt = msgs.get(msgs.size() - 1);
      long accTotal = Long.parseLong(property) - messageExt.getQueueOffset();
      ```
   
      With the batch [10, 5] from the new test and MAX_OFFSET = 20, `msgAccCnt` 
becomes 15 instead of 10. It only affects the accumulation metric, not offsets, 
so it could be a follow-up rather than part of this PR. Would it make sense to 
compute it from `this.queueOffsetMax` (after the loop) instead?
   
   3. Minor question: in which real path can a pulled batch arrive out of 
offset order? A sentence about that in the issue/PR would help reviewers judge 
the impact.
   
   The new test reproduces the issue clearly (6L before the fix, 11L after).


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