Skip to content

[ISSUE #11489] Improve POP KV ACK and ChangeInvisibleTime performance with group commit - #11490

Closed
qianye1001 wants to merge 6 commits into
apache:developfrom
qianye1001:codex/pop-kv-group-commit
Closed

qianye1001 wants to merge 6 commits into
apache:developfrom
qianye1001:codex/pop-kv-group-commit

Conversation

@qianye1001

@qianye1001 qianye1001 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Brief Description

With POP KV enabled, ACK and ChangeInvisibleTime can occupy the shared ACK executor while waiting for synchronous RocksDB WAL writes or write stalls. This queues persistence on one ServiceThread and completes requests asynchronously after the required writes succeed.

The writer handles explicit POP, ACK, CHANGE, cache-transfer and cache-clear tasks alongside storage writes. Consecutive tasks of the same type share an ordered WriteBatch; a type change commits the preceding batch before examining cache state. Transfer and clear tasks run individually. This keeps task ordering direct, without a generic state-update API or per-message dependency tracking. Mixed operation types can therefore produce smaller batches than a dependency-based scheduler.

Cache selection, persistence and removal now execute on that same writer. If cache transfer runs first, CHANGE replaces the persisted old checkpoint successfully. If CHANGE runs first, transfer cannot select and restore the old checkpoint. CHANGE's put/delete operations are atomic, and cache removal follows successful persistence. Failed transfers retain staged records; subsequent CHANGE/ACK also deletes an old disk key whose preceding write outcome was uncertain. A cache-hit ACK still avoids a disk write.

The queue is unbounded. Each batch has a 128-request limit and a 1 MiB target, keeping larger atomic requests intact. WAL and sync=true are retained. Responses run on a separate completion pool (default 4 workers, configurable with popConsumerKVCompletionThreadPoolNums), one task per request. Shutdown drains accepted writes and callbacks before closing RocksDB. Synchronous compatibility calls use private Futures so completion workers can safely submit and wait for another write.

ACK, batch ACK and CHANGE wait asynchronously for persistence; POP KV CHANGE no longer blocks the request executor when the legacy async flags are disabled. POP persistence failures produce an error response and release message buffers. Background persistence uses the same writer, and revive advances its scan cursor only after persistence succeeds. The cache-transfer race is covered here; the external RocksDB-expiry revive flow remains outside the state writer.

How Did You Test This Change?

Using JDK 21 with the protocol submodule initialized:

mvn -B -pl broker -am test \
  -Dtest='PopConsumer*Test,PopKVAsyncProcessorTest,AckMessageProcessorTest,ChangeInvisibleTimeProcessorTest,PopMessageProcessorTest' \
  -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false -Djacoco.skip=true

101 tests, 0 failures, 0 errors, 1 pre-existing skipped test. Checkstyle and SpotBugs passed.

Coverage includes both orderings of cache transfer versus CHANGE, transfer versus ACK, failed/uncertain transfers, cached-checkpoint preservation, consecutive CHANGE and ACK batching, queued POP → CHANGE → ACK ordering, native RocksDB persistence/reopen checks, size limits, shutdown draining, callback concurrency and reentrant writes, and asynchronous processor response timing/errors.

JaCoCo 0.8.5 is skipped because it does not support JDK 21. End-to-end throughput and crash-recovery behavior have not been benchmarked by this validation.

@qianye1001 qianye1001 closed this Oct 23, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.01824% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.96%. Comparing base (8ab8191) to head (e2bc827).

Files with missing lines Patch % Lines
...ketmq/broker/pop/PopConsumerWriteBatchService.java 87.58% 13 Missing and 6 partials ⚠️
...e/rocketmq/broker/pop/PopConsumerRocksdbStore.java 71.42% 9 Missing and 5 partials ⚠️
...g/apache/rocketmq/broker/pop/PopConsumerCache.java 94.28% 1 Missing and 3 partials ⚠️
...rocketmq/broker/processor/AckMessageProcessor.java 82.35% 3 Missing ⚠️
.../java/org/apache/rocketmq/common/BrokerConfig.java 25.00% 3 Missing ⚠️
...apache/rocketmq/broker/pop/PopConsumerService.java 90.47% 2 Missing ⚠️
...broker/processor/ChangeInvisibleTimeProcessor.java 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #11490      +/-   ##
=============================================
+ Coverage      49.78%   49.96%   +0.17%     
- Complexity     14391    14512     +121     
=============================================
  Files           1391     1393       +2     
  Lines         103350   103589     +239     
  Branches       13518    13554      +36     
=============================================
+ Hits           51455    51756     +301     
+ Misses         45680    45603      -77     
- Partials        6215     6230      +15     

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

[Enhancement] Improve ACK and ChangeInvisibleTime performance with POP KV group commit

2 participants