Repository navigation
[GC] GC24: Floor new WAL heads at N>1, retire the failed-sync mask with its flush, fence late sync groups - #20
Closed
JustinGaoF wants to merge 1 commit into
Closed
JustinGaoF wants to merge 1 commit into
JustinGaoF wants to merge 1 commit into
Conversation
…th its flush, fence late sync groups
[GC] GC24
Reviewer question: Can recovery now keep a later write without an earlier synced one, can a failed sync write ever be seen, flushed or recovered, and does the mask always retire?
Short answer. Recovery no longer keeps a later write when an earlier synced record sat in a lost, untracked current WAL. Each WAL that Open creates without an attested predecessor span now carries the index floor in its head. The merge lowers its bound to that floor, so the loss surfaces as a hole (Q1). A failed gate sync's write stays hidden until Resume's flush drops it. MemPurge output inherits the mask (Q4). Every sync group is registered before it leaves its write group, so the failure's error section fences it wherever its gate is (Q3). The mask retires in the same superversion install that frees the last masked memtable, history memtables included, with no background wait (Q2). Q5 to Q10 are evidence; Q8 is under Not done.
Tests ported from the losing candidates (Muse), with credit comments in the code:
- From GC21 (pwal/ab/gc21-muse-PR17): FailedGateSyncFencesCoalescedWaiterAtomically, FailedSyncRangeDeletionHiddenUntilResumeDropsIt (retirement check unmodified), FailedZeroCountSyncLeavesNoIndeterminateRecord (gap count mapped to TEST_HasIndeterminateWriteSequence), and from FailedHoleExplanationFailsResume the open-ended fence check, the second fail/Resume cycle and the 4-mode reopen (in FailedHoleExplanationFailsResume here, which uses a real fault).
- From GC23 (pwal/ab/gc23-muse-PR19): GC23MisplacedSupersessionFailsSequentialReplay and its helper MoveWALSupersessionsLast.
## Answers
### Q1. A lost current WAL below a survivor (D-GC24a option (i))
Property: no mode keeps a write while losing an earlier synced write that sat in a lost current WAL. Absolute, tolerate and skip fail with Corruption at the hole. Skip fails as documented for unexplained holes. Point-in-time opens the prefix below it.
How:
- DBImpl::WriteWALIndexHeadFloors (db_impl_open.cc) runs at N>1 with indexed WALs, right after WriteWALIndexSupersessions. Into the head of each WAL that Open created whose predecessor span is missing or names nothing allocated, it writes one existing progress record (kWALIndexProgressType) carrying next_wal_index_.
- A progress bound means "every index allocated from here on is at or above it". So every index the lost WAL bore lies above the floor of the surviving WAL that Open created alongside it.
- WALIndexMerger::ComputeLowerBound lowers its bound to each member's head floor, a progress bound read before the member's first data record (ReaderMember::HeadFloor). The lost index then lies inside the merged range and is a hole.
- WALs created by rotation already carry a span with last = the global high, so they need nothing.
- No new record type and no MANIFEST write. The added cost is one 15-byte control record (19 bytes with recycled WALs) per partition per Open whose span is missing. Nothing is added per write or per sync. Measured (release db_bench fillseq --num=10000 at N=8, partition_by_column_family): a fresh DB's WALs total 1460350 bytes at the base and 1460455 at this commit (+105 = seven floors; partition 0 carries an attested span). A reopen whose new WALs carry spans: 332 vs 332 bytes.
Evidence:
- GC23MissingCurrentIndexedWalAfterPrefix: the "lost record below" cells flip (invariant 3 exception, argued under Assumptions). Before: every mode OK, with "kept" present and "lost" missing. After: tolerate, absolute and skip return Corruption; point-in-time opens with 0 indexed records.
- New GC24LostCurrentWalBelowSurvivorIsAHole: N in {2, 8}, with and without manual_wal_flush, upgrade from kNone, the same four cells.
Neuters (each run, each fails):
- Writer side (write_floors = false): every mode opens with "kept" and without "lost"; both tests fail.
- Merge side (use_head_floors = false): same failures.
### Q2. The mask always retires, in step with Flush()
Property: once Resume's flush has dropped the failed groups' entries, the mask retires in the superversion install that frees the last masked memtable. After Resume() plus Flush() return, TEST_WalGateReadMaskRanges() is null with no background wait. No failed write is visible after retirement.
How:
- MemTableListVersion::Remove does not keep a masked memtable as history: kept there it would stay referenced, and with it the mask, indefinitely under max_write_buffer_size_to_maintain = -1. Behaviour change (argued, not tested): a conflict check that would have used that memtable acts as if history were trimmed (TransactionUtil::CheckKey). A pessimistic transaction reads SSTs instead; a cache-only (optimistic) check returns TryAgain. Neither validates against the failed group's entries.
- ReadOnlyMemTable::Unref drops the memtable's ranges at the final unref. Previously they went at deletion, which happens later, outside the mutex.
- DBImpl::InstallSuperVersionAndScheduleWork calls MaybeRetireWalGateReadMasks right after each install, so retirement happens in the install that Flush() waits for. The BackgroundCallFlush call site stays.
- wal_gate_masked_memtables_ keeps a weak_ptr per install, so memtables masked by an earlier failure still count until they are released.
- Weaker ordering, stated and pinned: a read that still holds an older superversion delays retirement until the next install or background flush after it releases. The read's own memtables keep their per-memtable masks meanwhile, so nothing becomes visible.
Evidence:
- New FailedGateSyncMaskRetiresUnderTransactionDB (TransactionDB, default options, max_write_buffer_size_to_maintain != 0): failed sync, then Resume(), Flush(), mask null; the failed key is absent through Get, MultiGet, a plain iterator and a tailing iterator, and after a reopen.
- Ported FailedSyncRangeDeletionHiddenUntilResumeDropsIt, retirement check unmodified.
- Both run 100x: 0 failures in 300 test-iterations (pristine binary, in the neuter session), plus the 100x gate below.
Neuters:
- Keep masked memtables in history (GC21's weak_ptr wait): the TransactionDB test fails, mask non-null.
- Retire before the drop (Resume's flush keeps the failed entries via empty drop ranges, so the mask retires when the memtable is freed): both tests fail and the failed key reads back.
- No retirement at the superversion install: Muse's retirement check fails 15/100.
- Masks dropped at deletion instead of at the final Unref: fails 12/100.
- Not caught by any test, argued only: a single weak_ptr in place of the per-install list; retiring at every call while masked (memtables keep their own masks, so retiring early exposes nothing).
### Q3. A late group is fenced before anything can flush it
Property: a group whose gate sync fails is fenced and masked in the mutex_ section that records the failure, whatever order the group, the error section and the coalescer run in. Fences stay exact (D-7).
How:
- WriteImpl and WriteImplWALOnly register each sync group that consumes sequences when its completion gate is installed (RegisterGateSyncGroup), before the memtable insert and before the group leaves the write group.
- The WALIOStatusCheck intent branch fences every registered or queued unfenced waiter, setting fenced and status, except the runner's own range. Each fence is [low, target].
- RunCoalescedGateSync uses the registration as its waiter. EndGateSyncGroup ends the registration and returns the fencing failure to a gate that otherwise succeeded.
- InstallWalGateFence now always signals the durability CV, because an exact fence can now be installed for a gate that is still parked.
- A memtable switch waits only for groups still in the write group. A registered group is fenced before any flush can pick its memtable.
Evidence:
- New LateSyncGroupFencedWithTheFailure: a published group G is held at DBImpl::CompletionGate:BeforeCoalescedSync while another gate sync fails and auto-resume runs its recovery flush; then G is released. G fails, and in all 4 modes the reopen does not have G's write but does have writes acknowledged after recovery.
- Ported FailedGateSyncFencesCoalescedWaiterAtomically.
Neuters:
- No registration (fence late, as before): LateSyncGroupFencedWithTheFailure fails; G is acknowledged and its write survives the reopen.
- No fencing of waiters in the error section: both tests fail; the coalesced waiter's key survives the reopen.
### Q4. All flush paths drop masked range tombstones
Property: MemPurge output never carries a failed group's entries without the mask. The timestamp-stripping path cannot meet a mask.
How:
- MemPurge honors drop_entries_at_or_above_ and drop_entry_ranges_ like a flush: it reads range deletions at the drop floor and wraps the merged input in SequenceFloorIterator.
- A failed gate sync can mask MemPurge's inputs after they were picked. The output memtable therefore inherits the inputs' masked ranges before it is installed, keeps hiding the same entries, and keeps the mask alive until it is released, so Resume's flush then drops them.
- Timestamp stripping (persist_user_defined_timestamps = false) requires allow_concurrent_memtable_write = false, which wal_partitions > 1 rejects. Masks exist only above one partition, so that path cannot meet one; db/memtable.cc is unchanged.
Evidence:
- New FailedGateSyncRangeDeletionHiddenAfterMemPurge (MemPurge enabled; purges == 1 asserted): k1 and k2 stay visible and "w" hidden before Resume, after Resume plus a flush, and after a reopen.
- New StrippingFlushNeverMeetsAMask pins that both N=2 option combinations are refused (NotSupported, message checked).
Neuters:
- Output does not inherit the mask: k1 and k2 read NotFound after the flush (the deletion applies).
- The stripping pin: argued, not tested beyond the refusal it pins.
### Q5. Resume makes progress, and a real fault on the explanation is handled
Property: on the retry-flush path, automatic recovery explains the burned index and clears the error. A real I/O fault on the explanation's append leaves the DB stopped, and a second Resume() rotates past the poisoned WAL and succeeds.
How: no code for the retry-flush path; it was reproduced not to stall. From the LOG:
1. The burning write's WAL error fails the in-flight retry-flush attempt ("DB resume requested but failed due to Flush failure").
2. The next automatic attempt runs as WAL write-error recovery: an atomic flush of every column family, which switches memtables and rotates every WAL.
3. The burned index is then explained on partition 0's new WAL.
For the fault, ExplainBurnedWALIndices gains one sync-point callback, DBImpl::ExplainBurnedWALIndices:Target, so a test can arm the real file system on the target WAL.
Evidence:
- New RetryFlushResumeExplainsBurnedIndex: the retry flush (kErrorRecoveryRetryFlush) is held while partition 1's WAL append fails and burns an index. Automatic recovery clears the error with no explanation failure, writes are admitted, and all 4 modes reopen with them.
- New FailedHoleExplanationFailsResume: FailingWalFS fails the void append on the target WAL. Resume() fails, the background error and the open-ended fence stay, and writes are refused. The second Resume() succeeds. A second fail/Resume cycle and the 4-mode reopen are ported from Muse.
Neuters:
- Drop `WalEmpty(0) = false` in ExplainBurnedWALIndices: the second Resume() reuses the poisoned WAL and the test fails.
- Retry path: no code was added, so there is no neuter. The candidate escalation neuter (no recovery-context replacement in CheckAndSetRecoveryAndBGError) does not stall it; the test still passes.
### Q6. A post-cut void on a read-write point-in-time open
Property: the open fails closed and names the pending index. Chosen over opening the prefix: the prefix open would need the end-of-recovery reissue check loosened, and later writes would sit above an unexplained superseded index. Muse's seed-past-voids hunk was studied, not ported; GC23VoidExceptionPreAndPostCut is not ported because it expects the prefix to open.
How:
- WALIndexMerger records whether the kFrontier stop is a pending superseded-only index (FrontierIsPendingDiscard).
- ProcessLogFilesMerged appends "; point-in-time recovery stopped at superseded-only wal_index N, which no void older than its cut explains; open read-only to read the prefix below it" to both "a write would reissue it" refusals.
- No check is loosened.
Evidence: GC23VoidAgainstPendingSupersededIndex at N in {2, 8}. Read-only point-in-time holds only k0 and k1. Read-write point-in-time now also requires the message to name k2's index. Invariant 4 exception: Q6 changes this GC23 test explicitly; it only adds a requirement.
Neuter: drop the clause (today's message): the test fails.
### Q7. GC23's recovery flush at N>1
New GC24SkippedSupersededHoleFlushesAtNAboveOne, N in {2, 8}: every mode opens with k0, k1, a and b and without k2 to k4.
Neuter: remove the SkippedUnexplainedDiscard flush. The N=2 point-in-time reopen loses b; tolerate and absolute fail on an unexplained hole.
### Q8. Floor scope on upgrade: Not done (see below).
### Q9. Ports
Each ported test passes, and its neuter was run:
- FailedGateSyncFencesCoalescedWaiterAtomically: no waiter fencing in the error section; the waiter's key survives the reopen.
- FailedZeroCountSyncLeavesNoIndeterminateRecord: fence the zero-count group as [target, target] in place of the low > high return; the indeterminate assertion fails.
- FailedHoleExplanationFailsResume (listed parts): see Q5.
- GC23MisplacedSupersessionFailsSequentialReplay with MoveWALSupersessionsLast: remove ProcessLogFile's misplaced-supersession guard; the sequential open no longer fails with "supersession after a data record".
- FailedSyncRangeDeletionHiddenUntilResumeDropsIt: see Q2.
### Q10. Evidence the earlier rounds asked for
- Read cost: paired, interleaved, base then commit, 3 runs each, release builds, N=8. Load average 8.4 to 12.7 throughout, all on a 166-core host.
db_bench (DB filled by fillrandom, 1M keys, 100-byte values, no compression; --enable_pipelined_write=0, which N>1 requires), ops/sec, runs 1/2/3 (median):
| benchmark | base | commit |
|---|---|---|
| readrandom, 1M reads | 185258 / 175602 / 181523 (181523) | 187682 / 189702 / 179559 (187682) |
| seekrandom, tailing iterator, 10 nexts, 200k seeks | 85858 / 85950 / 86016 (85950) | 86902 / 86298 / 86036 (86298) |
db_bench cannot fail a WAL sync, so the three phases come from an uncommitted harness (mask_read_cost.cc) linked against each build's release librocksdb.a and run in the same interleaved loop:
- Setup: N=8, 200k keys with 100-byte values, half in an SST and half in the memtable.
- Each phase measures 1M random Gets, then 100k tailing-iterator seeks with 10 nexts each.
- "mask_live": a sync write's WAL Sync is held by a FileSystem wrapper while an async write above it publishes, then fails. The failed key reads NotFound.
- "retired": after Resume() and Flush(), with the odd keys rewritten into a new memtable.
Ops/sec, runs 1/2/3 (median):
| phase | metric | base | commit |
|---|---|---|---|
| before | readrandom | 512087 / 489276 / 492777 (492777) | 474596 / 486776 / 519999 (486776) |
| before | tailing seek | 246480 / 239584 / 234626 (239584) | 216710 / 240196 / 246350 (240196) |
| mask live | readrandom | 505075 / 483306 / 495764 (495764) | 468106 / 496524 / 500175 (496524) |
| mask live | tailing seek | 247158 / 234868 / 246641 (246641) | 225170 / 237329 / 247076 (237329) |
| retired | readrandom | 364097 / 345068 / 339359 (345068) | 341159 / 356600 / 357985 (356600) |
| retired | tailing seek | 158427 / 150773 / 149989 (150773) | 147938 / 152165 / 156759 (152165) |
The retired phase has two SSTs plus a memtable, so it is not comparable with the other phases. A release build cannot read the mask state, so the harness does not check whether the base had retired its mask by the retired phase.
- Release build: GC23TimestampedSnapshotsSurviveFlushStress's value check, copied into an uncommitted public-API harness, built with DEBUG_LEVEL=0 against this commit's librocksdb.a. Hot column family = the first one created, since TEST_WalPartitionForWrite is debug-only. 20 iterations at N in {2, 8}, 494 to 579 snapshots per run: 0 failures. transaction_test still does not build with NDEBUG (92 SyncPoint uses). No build file changed.
- Opposite Q7 neuter: count live reservations and subtract them in InternalStats::HandleNumSnapshots. GC23SnapshotReservationInProperties fails, reading 0 snapshots while T1 is held (expects 1).
## Fold-back split
Blame at the base plus the Differential Revision line. GC winner commits carry no such line; per the doc, their lines count as the diff their round's split sent them to: GC18 and GC20 gate-sync lines go to D123551605, and GC21's fence, mask, retirement and explanation go to D123701876.
- Q1 -> D120624825 / D120649665:
- db/log_merge.h (HeadFloor virtual, ReaderMember override, head_floor_): new code -> D120649665 (merge membership).
- db/log_merge.cc (head_floor_ capture, HeadFloor, ComputeLowerBound floor term): new code inside D120624825's ComputeLowerBound -> D120624825.
- db/db_impl/db_impl_open.cc WriteWALIndexHeadFloors and its Open call, db/db_impl/db_impl.h declaration: new code, writer-side announcement -> D120649665, the diff whose purpose (recovering indexed WALs through the merge) it serves.
- db/db_wal_oracle_test.cc CatchesLowerBoundWithoutSpans: lines from D126533193 -> D126533193.
- db/db_write_test.cc GC23MissingCurrentIndexedWalAfterPrefix cells and comment: GC23 test lines -> D120649665.
- db/db_write_test.cc GC24LostCurrentWalBelowSurvivorIsAHole: new code -> D120649665.
- Q2 -> D123701876:
- db/memtable.h (DropMaskedSequenceRanges, GetMaskedSequenceRanges, Unref call): new code -> D123701876.
- db/memtable_list.cc Remove: modifies D71984601's line (upstream) -> D123701876, the mask's diff.
- db/db_impl/db_impl_compaction_flush.cc retirement call: new code -> D123701876.
- db/db_impl/db_impl_write.cc InstallFailedGateSyncFence and MaybeRetireWalGateReadMasks: GC21 lines -> D123701876.
- db/db_impl/db_impl.h comments and member type: GC21 lines -> D123701876.
- Tests FailedGateSyncMaskRetiresUnderTransactionDB and the ported FailedSyncRangeDeletionHiddenUntilResumeDropsIt -> D123701876.
- Q3 -> D123551605 and D123701876:
- RegisterGateSyncGroup, EndGateSyncGroup, WalGateSyncWaiter::status, the WriteImpl and WriteImplWALOnly registration, and the RunCompletionGate / RunCoalescedGateSync group parameter: lines from D123551605 and GC18/GC20/GC21 gate-sync lines -> D123551605.
- WALIOStatusCheck intent branch: GC21 lines -> D123701876.
- InstallWalGateFence signal: GC20 lines -> D123701876.
- Tests LateSyncGroupFencedWithTheFailure and ported FailedGateSyncFencesCoalescedWaiterAtomically -> D123551605.
- Q4 -> D123701876:
- db/flush_job.cc MemPurge: modifies upstream lines from D37916564, D55254362 and D29619283, plus new code -> D123701876.
- Tests FailedGateSyncRangeDeletionHiddenAfterMemPurge and StrippingFlushNeverMeetsAMask -> D123701876.
- Q5 -> D123701876:
- ExplainBurnedWALIndices sync point: GC21 lines -> D123701876.
- Tests FailedHoleExplanationFailsResume and RetryFlushResumeExplainsBurnedIndex -> D123701876. Nothing touches D123928339's ResumeImpl call site.
- Q6 -> D120649665 and D123928339:
- log_merge.h frontier_pending_discard_ and FrontierIsPendingDiscard: new code -> D120649665.
- db_impl_open.cc pending_discard_stop in the frontier loop: new code -> D120649665.
- pending_stop and the two refusals: the void check from D123928339 and the live-index check from D120649665 -> each to its own.
- GC23VoidAgainstPendingSupersededIndex: GC23 test lines -> D120649665.
- Q7 -> D120649665: GC24SkippedSupersededHoleFlushesAtNAboveOne, new test.
- Q9: GC21 ports -> D123701876 (listed above); GC23 port (db/db_wal_test.cc MoveWALSupersessionsLast and GC23MisplacedSupersessionFailsSequentialReplay) -> D121636079; FailedZeroCountSyncLeavesNoIndeterminateRecord -> D123701876.
- Q10: no committed change.
## Assumptions
1. D-GC24a was blank, so option (i) is implemented: an index floor announced in each new WAL that lacks an attested span, using the existing progress record type, and a merge rule. No MANIFEST write.
2. Invariant 3 exception: the "lost record below" cells of GC23MissingCurrentIndexedWalAfterPrefix encoded the bug the doc names. Their expectations changed; the setup is unchanged.
3. Invariant 4 exception: GC23VoidAgainstPendingSupersededIndex gains one requirement, the named index (Q6).
4. db_wal_oracle_test CatchesLowerBoundWithoutSpans also turns the head floors off (sync point WALIndexMerger::ComputeLowerBound:UseHeadFloors). Its G-20 injection removes the spans to prove the oracle catches a lower bound without witnesses. The head floors are a second witness that would otherwise catch the injected bug at cycle 0, before the oracle. With both removed the oracle catches it, at cycle 2.
5. Q2: the doc lets history memtables either drop the data or hide it without a mask. This drops it: masked memtables skip history entirely. That is the least code, and conflict checks fall back as they do when history is trimmed (SST read, or TryAgain when cache-only). It applies only after a failed gate sync, at N>1.
6. Q4: the timestamp-stripping path is unreachable at N>1 (the option combination is refused), so it is pinned rather than changed.
7. Q5: the retry-flush path needs no code (reproduced, mechanism above). Only a test hook was added for the real fault.
8. Q6: fail closed with the named index, not open the prefix: fail closed and least code.
9. Q10 release check: an uncommitted harness (public API only) rather than a new build target. That is the least code, with no Makefile, src.mk, CMake or BUCK change; the harness and its results are listed in the test plan.
10. Q10 read cost: db_bench cannot fail a WAL sync, so the mask-live and retired phases come from an uncommitted harness run on both builds, interleaved. The before-failure phase is also measured with db_bench.
11. The base's -base worktree held the base release build; the commit's release build was made in a copy of the working tree under -tmp, so the debug objects in the clone stayed intact.
## Not done (reverse order of work)
- Q8: the upgrade floor-scope test (empty DB at N=1, reopened at N=2 with a torn first record). Probes, starting from an indexed or a kNone N=1 DB with head floors on or off, using byte flips and truncation of the first record, never reached "head damaged and unattested":
- Point-in-time and skip open, keeping k1.
- Tolerate and absolute fail with a checksum mismatch, or a truncated record body under absolute.
- With the indexed start, partition 0's [0,0] span names the retired N=1 WAL and anchors the head. The kNone start's reason is untraced.
- The history floor was off in every probe. No test, so no neuter.
- Muse's GC23VoidExceptionPreAndPostCut is not ported: Q6 fails closed instead.
## Test plan
All commands run from the clone with TEST_TMPDIR=~/pwal-3p/gc-24-claude-tmp and J=83 (166 cores).
1. Debug suites. `make -j83` of all 10 binaries, then `python3 build_tools/gtest-parallel -w 83` over db_write_test, db_wal_test, log_merge_test, log_test, db_secondary_test, transaction_test, db_wal_oracle_test, db_basic_test, db_options_test and write_callback_test. Result: 7164/7164 passed (the base has 7149). Peak load average 73.5.
2. Repeats, 100x, of every SyncPoint-driven or fault-injection new or changed test. `gtest-parallel -w 20 --repeat=100`:
- db_write_test with filter *FailedGateSyncFencesCoalescedWaiterAtomically*, *FailedSyncRangeDeletionHiddenUntilResumeDropsIt*, *FailedZeroCountSyncLeavesNoIndeterminateRecord*, *FailedGateSyncMaskRetiresUnderTransactionDB*, *FailedHoleExplanationFailsResume*, *RetryFlushResumeExplainsBurnedIndex*, *LateSyncGroupFencedWithTheFailure*, *FailedGateSyncRangeDeletionHiddenAfterMemPurge*, *GC24LostCurrentWalBelowSurvivorIsAHole*, *GC23MissingCurrentIndexedWalAfterPrefix*, *GC24SkippedSupersededHoleFlushesAtNAboveOne*, *GC23VoidAgainstPendingSupersededIndex* and *StrippingFlushNeverMeetsAMask*: 1600/1600 passed (16 instances, including GetParam() = true instances that return early).
- db_wal_test *GC23MisplacedSupersessionFailsSequentialReplay*: 100/100.
- db_wal_oracle_test *CatchesLowerBoundWithoutSpans*: 100/100.
- Separately, the two Q2 tests: 300/300 (0 failures) on the pristine binary in the neuter session.
3. TSan. `USE_CLANG=1 COMPILE_WITH_TSAN=1 AUTO_CLEAN=1 make -j60 db_write_test db_wal_test db_wal_oracle_test transaction_test` (clang 21.1.0), in a pristine copy of the tree under -tmp, so the clone's debug objects stayed in place. The same filters, TSAN_OPTIONS=halt_on_error=1: 16 + 1 + 1 tests passed, 0 ThreadSanitizer warnings.
4. Neuters, each by patching the working tree with an exact-match script:
- The script checks the patched file's SHA-256 changed and that make recompiled it.
- Each run restores with a fresh mtime and is followed by a pristine rebuild and a hash check.
- Results are in each question's section; every neuter listed fails as stated, except those marked argued, not tested.
- A first batch was discarded: its restore kept old mtimes, so later neuter binaries carried earlier neuters. Every neuter was rerun.
5. GC15 oracle. `ROCKSDB_WAL_ORACLE_CYCLES=250` with ROCKSDB_WAL_ORACLE_SEED in 20261019, 20261269, 20261519 and 20261769, run in parallel, so seeds 20261019 to 20262018. Result: 1000 cycles, 0 violations. N=2 in 507 and N=8 in 493; power loss in 528, and it lost an acknowledged write in 375.
6. N=1 byte identity. Release db_bench (`DEBUG_LEVEL=0`) at the base (-base worktree at d6ada40) and at this commit, with `--benchmarks=fillseq --threads=1 --num=10000 --seed=20260928 --disable_auto_compactions=1`. SHA-256 of 000004.log:
- partition_wal_usage=none: 6d1351117a289a2784449a68d5421b1aa385ab0b383273c2c5918befa9181b09 at both.
- partition_by_column_family: 9a69a3fc66777fadce05e8a999479a5f57364aca27cd6d22aa00e4631adfc796 at both.
Identical. The commit-side release build was made from a copy of the tree. It differs from the commit only by a whitespace-only wrap in db_impl.h and a test comment, which db_bench does not build.
7. Q10 release value check. Uncommitted public-API harness, DEBUG_LEVEL=0, linked against this commit's release librocksdb.a, 20 iterations at N in {2, 8}: 0 failures.
8. Q10 read-cost A/B: tables under Q10, with uptime recorded per run.
9. Q1 added cost: under Q1.
10. Format and sources (clang-format 21.1.2):
- `make check-format` before committing: "Nothing needs to be reformatted!", after formatting this change's own lines.
- After committing, `FORMAT_UPSTREAM=d6ada40c8c13 make check-format`: "Nothing needs to be reformatted!". The default post-commit mode compares against the remote's HEAD branch, so it covers the whole unfolded stack: it reports code this commit does not touch and inserts copyright headers into four files new in the stack. Those insertions were reverted.
- `make check-sources`: passes.
11. db_stress: not run (not required).
JustinGaoF
force-pushed
the
pwal/gc24-claude
branch
from
October 29, 2026 17:56
86fa94a to
121a5a0
Compare
Owner
Author
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.
[GC] GC24
Reviewer question: Can recovery now keep a later write without an earlier synced one, can a failed sync write ever be seen, flushed or recovered, and does the mask always retire?
Short answer. Recovery no longer keeps a later write when an earlier synced record sat in a lost, untracked current WAL. Each WAL that Open creates without an attested predecessor span now carries the index floor in its head. The merge lowers its bound to that floor, so the loss surfaces as a hole (Q1). A failed gate sync's write stays hidden until Resume's flush drops it. MemPurge output inherits the mask (Q4). Every sync group is registered before it leaves its write group, so the failure's error section fences it wherever its gate is (Q3). The mask retires in the same superversion install that frees the last masked memtable, history memtables included, with no background wait (Q2). Q5 to Q10 are evidence; Q8 is under Not done.
Tests ported from the losing candidates (Muse), with credit comments in the code:
Answers
Q1. A lost current WAL below a survivor (D-GC24a option (i))
Property: no mode keeps a write while losing an earlier synced write that sat in a lost current WAL. Absolute, tolerate and skip fail with Corruption at the hole. Skip fails as documented for unexplained holes. Point-in-time opens the prefix below it.
How:
Evidence:
Neuters (each run, each fails):
Q2. The mask always retires, in step with Flush()
Property: once Resume's flush has dropped the failed groups' entries, the mask retires in the superversion install that frees the last masked memtable. After Resume() plus Flush() return, TEST_WalGateReadMaskRanges() is null with no background wait. No failed write is visible after retirement.
How:
Evidence:
Neuters:
Q3. A late group is fenced before anything can flush it
Property: a group whose gate sync fails is fenced and masked in the mutex_ section that records the failure, whatever order the group, the error section and the coalescer run in. Fences stay exact (D-7).
How:
Evidence:
Neuters:
Q4. All flush paths drop masked range tombstones
Property: MemPurge output never carries a failed group's entries without the mask. The timestamp-stripping path cannot meet a mask.
How:
Evidence:
Neuters:
Q5. Resume makes progress, and a real fault on the explanation is handled
Property: on the retry-flush path, automatic recovery explains the burned index and clears the error. A real I/O fault on the explanation's append leaves the DB stopped, and a second Resume() rotates past the poisoned WAL and succeeds.
How: no code for the retry-flush path; it was reproduced not to stall. From the LOG:
For the fault, ExplainBurnedWALIndices gains one sync-point callback, DBImpl::ExplainBurnedWALIndices:Target, so a test can arm the real file system on the target WAL.
Evidence:
Neuters:
WalEmpty(0) = falsein ExplainBurnedWALIndices: the second Resume() reuses the poisoned WAL and the test fails.Q6. A post-cut void on a read-write point-in-time open
Property: the open fails closed and names the pending index. Chosen over opening the prefix: the prefix open would need the end-of-recovery reissue check loosened, and later writes would sit above an unexplained superseded index. Muse's seed-past-voids hunk was studied, not ported; GC23VoidExceptionPreAndPostCut is not ported because it expects the prefix to open.
How:
Evidence: GC23VoidAgainstPendingSupersededIndex at N in {2, 8}. Read-only point-in-time holds only k0 and k1. Read-write point-in-time now also requires the message to name k2's index. Invariant 4 exception: Q6 changes this GC23 test explicitly; it only adds a requirement.
Neuter: drop the clause (today's message): the test fails.
Q7. GC23's recovery flush at N>1
New GC24SkippedSupersededHoleFlushesAtNAboveOne, N in {2, 8}: every mode opens with k0, k1, a and b and without k2 to k4.
Neuter: remove the SkippedUnexplainedDiscard flush. The N=2 point-in-time reopen loses b; tolerate and absolute fail on an unexplained hole.
Q8. Floor scope on upgrade: Not done (see below).
Q9. Ports
Each ported test passes, and its neuter was run:
Q10. Evidence the earlier rounds asked for
db_bench (DB filled by fillrandom, 1M keys, 100-byte values, no compression; --enable_pipelined_write=0, which N>1 requires), ops/sec, runs 1/2/3 (median):
db_bench cannot fail a WAL sync, so the three phases come from an uncommitted harness (mask_read_cost.cc) linked against each build's release librocksdb.a and run in the same interleaved loop:
Ops/sec, runs 1/2/3 (median):
The retired phase has two SSTs plus a memtable, so it is not comparable with the other phases. A release build cannot read the mask state, so the harness does not check whether the base had retired its mask by the retired phase.
Fold-back split
Blame at the base plus the Differential Revision line. GC winner commits carry no such line; per the doc, their lines count as the diff their round's split sent them to: GC18 and GC20 gate-sync lines go to D123551605, and GC21's fence, mask, retirement and explanation go to D123701876.
Assumptions
Not done (reverse order of work)
Test plan
All commands run from the clone with TEST_TMPDIR=~/pwal-3p/gc-24-claude-tmp and J=83 (166 cores).
make -j83of all 10 binaries, thenpython3 build_tools/gtest-parallel -w 83over db_write_test, db_wal_test, log_merge_test, log_test, db_secondary_test, transaction_test, db_wal_oracle_test, db_basic_test, db_options_test and write_callback_test. Result: 7164/7164 passed (the base has 7149). Peak load average 73.5.gtest-parallel -w 20 --repeat=100:USE_CLANG=1 COMPILE_WITH_TSAN=1 AUTO_CLEAN=1 make -j60 db_write_test db_wal_test db_wal_oracle_test transaction_test(clang 21.1.0), in a pristine copy of the tree under -tmp, so the clone's debug objects stayed in place. The same filters, TSAN_OPTIONS=halt_on_error=1: 16 + 1 + 1 tests passed, 0 ThreadSanitizer warnings.ROCKSDB_WAL_ORACLE_CYCLES=250with ROCKSDB_WAL_ORACLE_SEED in 20261019, 20261269, 20261519 and 20261769, run in parallel, so seeds 20261019 to 20262018. Result: 1000 cycles, 0 violations. N=2 in 507 and N=8 in 493; power loss in 528, and it lost an acknowledged write in 375.DEBUG_LEVEL=0) at the base (-base worktree at d6ada40) and at this commit, with--benchmarks=fillseq --threads=1 --num=10000 --seed=20260928 --disable_auto_compactions=1. SHA-256 of 000004.log:Identical. The commit-side release build was made from a copy of the tree. It differs from the commit only by a whitespace-only wrap in db_impl.h and a test comment, which db_bench does not build.
make check-formatbefore committing: "Nothing needs to be reformatted!", after formatting this change's own lines.FORMAT_UPSTREAM=d6ada40c8c13 make check-format: "Nothing needs to be reformatted!". The default post-commit mode compares against the remote's HEAD branch, so it covers the whole unfolded stack: it reports code this commit does not touch and inserts copyright headers into four files new in the stack. Those insertions were reverted.make check-sources: passes.