zjncs opened a new pull request, #11150:
URL: https://github.com/apache/rocketmq/pull/11150

   ### Motivation
   
   `estimateMessageCount` translated the exclusive upper bound `to` with 
`getBatchMsgIndexBuffer(to)`, which returns null when `to` equals 
`maxOffsetInQueue`. Every accumulation query that counts up to the queue head 
therefore hit the null branch and returned -1, and callers such as 
`DefaultMessageStore` silently fell back to the raw offset difference, ignoring 
batch sizes and tag filters.
   
   ### Modifications
   
   Since `to` is exclusive, look up the unit containing `to - 1` instead, and 
advance `physicalOffsetTo` past that unit so the scan covers it. Interior 
ranges are unaffected because a `to` that lands on a batch base resolves to the 
same mapped position as before.
   
   ### Verification
   
   Fail-before (new test, run against the unpatched code):
   
   ```
   Tests run: 6, Failures: 1, Errors: 0 -- 
BatchConsumeQueueTest#testEstimateMessageCount
   java.lang.AssertionError: expected:<1000> but was:<-1>
     BatchConsumeQueueTest.testEstimateMessageCount:285 -- 
estimateMessageCount(1, 1001) with to == maxOffsetInQueue
   ```
   
   Pass-after:
   
   ```
   Tests run: 6, Failures: 0, Errors: 0, Skipped: 0 -- BatchConsumeQueueTest
   ```
   


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