[ISSUE #10949] Improve pop consumer offset committing - #10964
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #10964 +/- ##
=============================================
- Coverage 48.58% 48.54% -0.05%
- Complexity 13671 13672 +1
=============================================
Files 1381 1381
Lines 101475 101534 +59
Branches 13189 13198 +9
=============================================
- Hits 49302 49290 -12
- Misses 46176 46235 +59
- Partials 5997 6009 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR improves the pop consumer offset committing mechanism by introducing a pending commit offset pattern that ensures offsets are committed only after pop operations complete, and adds lock acquisition in cleanupRecords to prevent concurrent eviction during pop writes.
The changes are well-structured and address a real concurrency issue. The use of volatile for pendingCommitOffset and CAS-based advancePendingCommitOffset ensures thread safety. The lock acquisition in cleanupRecords (matching the popAsync lock) correctly prevents race conditions.
LGTM — no blocking issues found.
Automated review by github-manager-bot
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Improves pop consumer offset committing by deferring the commit until after the pop operation completes, using a pending commit mechanism. This ensures the committed offset reflects the actual nextBeginOffset of each pop round rather than lagging one round behind.
Review
- Correctness ✅ — The pending commit approach is sound: offsets are collected during
handleGetMessageResultand committed after the pop future completes incommitPendingOffset. The cache-aware capping (getMinOffsetInCache) correctly prevents committing past unacknowledged cached records. - Concurrency ✅ — The added
consumerLockService.tryLock()incleanupRecordsprevents evicting records that a concurrent pop is still writing. The lock scope is appropriate. - FIFO vs non-FIFO ✅ — FIFO path correctly commits immediately (offset = consume start point). Non-FIFO path defers via pending commits, which is the right trade-off for throughput.
- Edge cases —
commitPendingOffsethandles nullpendingCommitListgracefully. TheKeyBuilder.parseNormalTopicusage for the lock key is consistent with existing patterns. - Tests ✅ — New
PopConsumerServiceCommitOffsetTestcovers the pending commit flow.
One minor note: the setPendingCommitOffset method in PopConsumerCache silently no-ops if consumerRecords is null — this is fine but worth a debug log if it becomes a diagnostic pain point.
LGTM — well-structured improvement to offset semantics with proper concurrency handling.
Automated review by github-manager-bot
Which Issue(s) This PR Fixes
Brief Description
How Did You Test This Change?
Minimum verification test. Check whether the consumer offsets have been advanced.