Skip to content

[ISSUE #10453] fix unexpected decrement of lmq counter#10454

Open
imzs wants to merge 1 commit into
apache:developfrom
imzs:fix-lmq-counter
Open

[ISSUE #10453] fix unexpected decrement of lmq counter#10454
imzs wants to merge 1 commit into
apache:developfrom
imzs:fix-lmq-counter

Conversation

@imzs

@imzs imzs commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

#10453 fix unexpected decrement of lmq counter.

@oss-sentinel-ai oss-sentinel-ai left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 != -1L before decrementing lmqCounter. 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_decrement correctly verifies:
    1. Getting max offset for a non-existent LMQ topic returns null without incrementing counter
    2. 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-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.02%. Comparing base (ef6a8c9) to head (7b8a041).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants