[ISSUE #10453] fix unexpected decrement of lmq counter#10454
Open
imzs wants to merge 1 commit into
Open
Conversation
oss-sentinel-ai
approved these changes
Jun 9, 2026
oss-sentinel-ai
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
This PR fixes the LMQ counter underflow bug described in #10453. When a getMaxCqOffset call for a non-existent LMQ topic inserts a sentinel value -1L without incrementing lmqCounter, the subsequent deletion of that topic would incorrectly decrement the counter.
Findings
- [Good] RocksDBConsumeQueueOffsetTable.java:603-607 — The fix correctly checks
prev != -1Lbefore decrementinglmqCounter. This ensures the counter is only decremented for entries that were actually counted (i.e., had a real offset, not a sentinel). - [Good] RocksDBConsumeQueueOffsetTable.java:606 — Added a warning log for the edge case where a sentinel entry is being removed. This aids debugging and monitoring.
- [Good] RocksDBConsumeQueueOffsetTableTest.java:149-160 — New test
testLmqCounter_decrementcorrectly verifies:- Getting max offset for a non-existent LMQ topic returns null without incrementing counter
- Destroying that offset does not decrement the counter (counter stays at
initCount)
- [Good] Test setup properly adds required mocks (
columnFamilyHandle,messageStoreConfig) for the updated constructor.
Analysis
The fix is minimal, targeted, and correct:
- The root cause is a counter invariant violation: sentinel value insertion doesn't increment, but deletion decrements
- The fix restores the invariant by checking the sentinel value before decrementing
- No backward compatibility concerns — this is a pure bug fix
Verdict
✅ Approved — Clean, minimal fix with proper test coverage for the counter underflow bug.
Automated review by github-manager-bot
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #10454 +/- ##
=============================================
- Coverage 48.07% 48.02% -0.06%
+ Complexity 13312 13301 -11
=============================================
Files 1377 1377
Lines 100632 100634 +2
Branches 12995 12996 +1
=============================================
- Hits 48378 48328 -50
- Misses 46327 46363 +36
- Partials 5927 5943 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
RongtongJin
approved these changes
Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#10453 fix unexpected decrement of lmq counter.