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

   **Issue Evaluation**
   
   Category: `type/bug` | Status: **Confirmed**
   
   The reported issue has been verified against the current codebase (commit 
`293f5885`).
   
   **Root Cause:** In `DefaultMessageStore.estimateMessageCount` (line ~3189), 
when `from` is below `minOffset`, the range is shifted right by preserving its 
length (`to = from + diff`), but `to` is never clamped to the ConsumeQueue's 
`maxOffset`. This allows the shifted upper bound to exceed the readable 
boundary of the ConsumeQueue.
   
   **Impact:** Any consumer or admin call relying on this estimate (e.g., lag 
metrics via `PeriodicMetricReader`, filtered message count) may receive 
incorrect results when the requested range starts before the queue's minimum 
offset. The `selectMappedBuffer` call returns `null` for out-of-range 
positions, producing repeated warnings and reporting zero filtered lag even 
when matching messages exist.
   
   **Severity:** Medium — No data corruption, but incorrect lag estimates can 
mislead monitoring dashboards, rebalancing logic, or reset-offset decisions.
   
   **Suggested Fix:** After shifting, clamp both endpoints to the valid range:
   ```java
   long diff = to - from;
   from = minOffset;
   to = from + diff;
   to = Math.min(to, maxOffset);  // clamp upper bound
   ```
   
   An automated fix proposal may be generated. Reply `/approve` to proceed with 
PR generation, or provide feedback if adjustments are needed.
   
   ---
   *Automated evaluation by github-manager*


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