Repository navigation
[ISSUE #11495] Disable inplace update for RocksDB consume queue offset column family - #11496
Open
leizhiyuan wants to merge 1 commit into
Open
leizhiyuan wants to merge 1 commit into
leizhiyuan wants to merge 1 commit into
Conversation
… offset column family
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #11496 +/- ##
==========================================
Coverage 49.81% 49.82%
+ Complexity 14405 14403 -2
==========================================
Files 1391 1391
Lines 103362 103361 -1
Branches 13519 13519
==========================================
+ Hits 51493 51499 +6
+ Misses 45652 45650 -2
+ Partials 6217 6212 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Which Issue(s) This PR Fixes
Brief Description
RocksDBOptionsFactory#createOffsetCFOptions()enabledsetInplaceUpdateSupport(true)on theoffsetcolumn family.RocksDBConsumeQueueStore#putMessagePosition0writes the CQ units (default CF) and the queue's MAX offset (offset CF) in oneWriteBatch, and readers such ascorrectMinCqOffsetrely on that batch being visible atomically. An in-place overwrite of an existing MAX key in the memtable is not protected by sequence-number visibility. A reader can therefore see the new MAX before the CQ units of the same batch. The first min lookup of a new queue then binary-searches a range whose entries are not visible yet and persists a min offset > 0, so consumers silently skip the first messages. See #11495 for the full analysis and standalone reproducers.This PR removes
setInplaceUpdateSupport(true)from the offset CF options. That is the only production change.Trade-off: without in-place update, every MAX update adds a new version to the memtable instead of overwriting the old one. The offset CF only holds a few keys per queue (MAX/MIN), and it already uses a 64 MB write buffer. Obsolete versions are dropped on flush/compaction, and point lookups still return only the latest visible version. The extra memtable usage and write cost are small, and in return the batch is atomic again. Data already on disk stays compatible; this option only affects memtable behavior.
ConfigHelper#createConfigColumnFamilyOptions(metadata storage) also enables in-place update, but it does not have this cross-CF batch visibility dependency, so it is out of scope here.How Did You Test This Change?
New tests in
RocksDBOptionsFactoryTest:testOffsetCFOptionsDisableInplaceUpdate: deterministic check thatcreateOffsetCFOptions()does not enable in-place update.testOffsetCFMaxOffsetVisibleWithConsumeQueueUnit: opens a RocksDB instance with the realcreateCQCFOptions/createOffsetCFOptionsand broker-like DB options. A writer puts a CQ unit and MAX into oneWriteBatch(likeputMessagePosition0), and 4 readers check thatCQ[MAX]is visible whenever MAX is visible. It runs for at most 3 seconds and stops at the first anomaly.Before the fix (develop), 3 out of 3 runs failed:
After the fix:
Tests run: 4, Failures: 0, stable over 6 runs.Related store tests (checkstyle enabled):
I also ran an end-to-end check against the real
RocksDBConsumeQueueStore. Each run did 1000 rounds of 200 fresh queues: batch1 ={offset 0}, then batch2 ={offsets 1..4}viaputMessagePosition, while 4 threads calledgetMinOffsetInQueue. Before the fix it occasionally left min offset = 4 (failures in 1 of 8 runs and in a few earlier runs). After the fix, 8 out of 8 runs reported 0 wrong min offsets. It is too timing-dependent to be a reliable unit test, so it is not included.