Repository navigation
Conversation
|
@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
1661e56 to
177e590
Compare
|
@ajkr has updated the pull request. You must reimport the pull request before landing. |
|
@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@ajkr has updated the pull request. You must reimport the pull request before landing. |
|
@ajkr has updated the pull request. You must reimport the pull request before landing. |
|
@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
1 similar comment
|
@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
cbi42
left a comment
There was a problem hiding this comment.
LGTM, thanks for the refactoring.
It turned out to not be pointless in case of atomic_flush=true. There, holding DB mutex is insufficient to craft a consistent Instead, I will assume everything has a point. In that case, how should write stalls and memtable flush retries interact? We could save the failed |
|
@ajkr has updated the pull request. You must reimport the pull request before landing. |
|
@ajkr has updated the pull request. You must reimport the pull request before landing. |
|
@ajkr has updated the pull request. You must reimport the pull request before landing. |
Instead of this, I inspected the state that is updated within a single DB mutex hold ( |
|
@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
1 similar comment
|
@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
LGTM still, nice fix. |
|
Thanks for the review! |
Summary: Recovery triggers flushes for very different scenarios: (1) `FlushReason::kErrorRecoveryRetryFlush`: a flush failed (2) `FlushReason::kErrorRecovery`: a WAL may be corrupted (3) `FlushReason::kCatchUpAfterErrorRecovery`: immutable memtables may have accumulated The old code called called `FlushAllColumnFamilies()` in all cases, which uses manual flush functions: `AtomicFlushMemTables()` and `FlushMemTable()`. Forcing flushing the latest data on all CFs was useful for (2) because it ensures all CFs move past the corrupted WAL. However, those code paths were overkill for (1) and (3), where only already-immutable memtables need to be flushed. There were conditionals to exclude some of the extraneous logic but I found there was still too much happening. For example, both of the manual flush functions enter the write thread. Entering the write thread is inconvenient because then we can't allow stalled writes to wait on a retrying flush to finish. Instead of continuing down the path of adding more conditionals to the manual flush functions, this PR introduces a dedicated function for cases (1) and (3): `RetryFlushesForErrorRecovery()`. Also I cleaned up the manual flush functions to remove existing conditionals for these cases as they're no longer needed. Pull Request resolved: meta#11903 Reviewed By: cbi42 Differential Revision: D49693812 Pulled By: ajkr fbshipit-source-id: 7630ac539b9d6c92052c13a3cdce53256134d990
…very modes follow D-10
[GC] GC26
Reviewer question: Do Resume, N changes and rollback now always leave the DB openable, and do the recovery modes follow D-10?
Short answer: yes, within the limits listed under Not done.
- Q1: before Resume voids a burned index, it reads that index back from the WAL. A record that landed whole is recovered and gets no void. A torn copy is zeroed durably and then voided. If the read-back fails, Resume fails.
- Q2: Open attests every recovered chain head, not only the newest WAL placed in each partition. Lowering wal_partitions while a prepare pins an old WAL therefore leaves no unexplained hole.
- Q3: an indexed set written at N>1 followed by unindexed WALs (a rollback to kNone) is merged and then replayed sequentially. An unindexed WAL between two indexed WALs (true alternation) still fails closed in every mode, which closes T6.
- Q4: skip skips unexplained holes, tolerate and absolute refuse them, and point-in-time opens the prefix. The WALRecoveryMode, wal_partitions and partition_wal_usage docs say so, and a release note is added.
- Q5: ports two GC24 items from Muse, adds the column-family refusal tests, removes three dead hooks and fixes the crash-test sanitizer.
There is no new record type, no format change and no MANIFEST change. N=1 output is byte-identical.
Ported from GC24's losing candidate (Muse, PR 21), with credit comments in the code:
- GC24HistoryFloorScopeOnUpgrade (Q5 (a)), unmodified.
- GC24RetryFlushRecoveryWithBurnedIndexProgresses and the retry-flush reason normalization in DBImpl::ResumeImpl that it tests (Q5 (b)).
## Answers
### Q1. Resume explains only what did not land (G3-A-2, D-GC25a)
Property: after a failed append burns an index at N>1, Resume writes a void only if no record with that index landed. A torn record counts as not landed. If Resume cannot read the WAL back, it fails and the DB stays stopped. In every case, every crash image taken after a successful Resume opens in all four modes with every acknowledged write.
How:
- CoverBurnedWALIndex records the writer's flushed size with each burned index (BurnedWalIndex::wal_offset, in memory only). That size is where the failed record starts.
- New DBImpl::BurnedWALIndexLanded reads the WAL back with log::Reader until it reaches the burned index:
- A record with exactly that index means it landed.
- A WAL that no longer exists has been retired; recovery cannot read it, so nothing contradicts a void.
- An I/O error while opening or reading the WAL fails the call.
- If the index was not found and the reader reported corruption or stopped before the end of the file, the bytes from wal_offset to the end of the file are the torn copy.
- ExplainBurnedWALIndices runs the read-back for each burned index with mutex_ released, before its existing block:
- Landed whole: no void. The WAL is synced through a fresh handle (FileSystem::SyncFile), because the failure poisoned its writer and the record must not vanish while writes above it survive.
- Torn: the torn bytes are overwritten with zeros through NewRandomRWFile and synced. Zeros read as padding (kZeroType). The file keeps the size the MANIFEST may track, so truncating it was ruled out. Resume's rotation has already appended a progress record behind the torn bytes. Without the zeroing, point-in-time and absolute would read the torn copy as a lost record below the writes Resume admits.
- Any I/O error stops the loop and skips the void block, so Resume fails.
- The write path, the completion gate and the read mask are unchanged. The db_impl_write.cc change is confined to ExplainBurnedWALIndices, its new helper and the one-field push in CoverBurnedWALIndex.
Evidence:
- New GC26ResumeExplainsOnlyWhatDidNotLand covers N in {2, 8}, with and without a prepare keeping the WAL live, and a landing of whole, torn or nothing (FailingWalFS::Landing). After Resume, every crash image opens in all four modes with every acknowledged write. Without 2PC the WAL is already retired before the read-back, so it is the 2PC cells that exercise the landed-whole and torn paths; the test checks the LOG lines there.
- New GC26ResumeFailsWhenBurnedIndexReadBackFails injects an I/O error into the read-back (sync point DBImpl::BurnedWALIndexLanded:Read). The first Resume fails with that error, writes stay refused, and a second Resume succeeds.
Neuters (each run; each one fails):
- Void every burned index, ignoring `landed`: the whole-record 2PC cells fail to open in every mode with "WAL index merge: index 4 bears records and a void cover".
- No zeroing of the torn copy: the torn 2PC cells fail with "WAL 24 holds a void over wal_index 4 at or above the next wal_index 3; a write would reissue it".
- Treat a read-back error as "retired": the first Resume succeeds, and three assertions fail.
### Q2. Open attests every recovered chain head (G3-B-1, D-GC25b)
Property: when wal_partitions decreases while a prepare pins an old WAL, the old partition 0 WAL can be deleted at the new N and every mode still opens with every acknowledged write and the prepare.
How:
- DBImpl::RecoveredWALIndexPredecessors(p), a new function that RecoveredWALIndexPredecessor now delegates to, builds one head per recorded partition: that partition's newest recovered WAL. A head recorded at a partition the new N no longer has is placed in partition 0, as before. The function returns every head placed in p, in ascending WAL order. Before this change only the newest WAL placed in p was attested, so the other folded chains were not.
- Open writes the first span exactly as before. New DBImpl::WriteFurtherWALIndexPredecessors writes the remaining spans of partition 0, right after partition 0's WAL is created, using the existing span record type. It follows the same recycle_log_file_num == 0 rule and the same sync point (DBImpl::StartWALFile:WriteSpan) as the first span. A partition p >= 1 holds at most one head, so it gets no further span.
- log::Reader accepts a second or later span only when its WAL number is strictly greater than the previous span's, and exposes the extra spans through GetFurtherWALIndexPredecessorSpans(). A span that repeats or goes backwards is reported as corruption ("attests two predecessor spans out of ascending WAL order"), as any second span was before. Readers that predate this change report the extra spans as corruption. Writing them needs a DB at N>1 lowering its N, and that combination exists only in this stack.
- WALIndexMerger::Member::AttestedSpans has a default that returns the one span; ReaderMember also returns the further spans. ComputeLowerBound uses all attested spans for folding and anchoring.
Evidence:
- New GC26PartitionReductionKeepsPrepare, run as a WritePrepared TransactionDB, lowers N from 4 to 2, 4 to 1 and 8 to 2, with 4 -> 4 as the control. The old partition 0 WAL is asserted deleted. In every mode the reopen holds every acknowledged write and the prepare, which then commits or rolls back.
- New LogMergeTest.FurtherSpanExplainsRetiredFoldedHead: the held WAL 121 attests 119:[4,6] and 120:[3,6], giving a bound of 121, and the merge emits 2, 5, 7.
- New LogTest.WALIndexFurtherPredecessorSpansAscend; the existing WALIndexSecondPredecessorSpanReportsCorruption (122 then 121) is unchanged and passes.
- ReopenWithChangedPartitionsWritesSpans now expects every head's span (invariant 4 exception; see Assumptions).
Neuters:
- Attest only the newest WAL per partition: the reduced cells fail with "unexplained hole at wal_index 4 with records above it; cannot bound". Point-in-time fails with "Column family inconsistency: SST file contains data beyond the point of corruption".
- Merge ignores the further spans: FurtherSpanExplainsRetiredFoldedHead fails.
### Q3. Unindexed suffix: merge, then replay sequentially; true alternation fails closed (G3-B-2, D-GC25c, T6)
Property: an indexed set written at N>1 followed by unindexed WALs opens in every mode. One case is a rollback to kNone while a prepare pins an old WAL. The indexed WALs are merged, then the unindexed WALs above all of them replay in file order. An unindexed WAL between two indexed WALs fails closed in every mode, and the message names the WALs on both sides.
How:
- CheckWALFilesCarryWALIndex also reports the highest indexed WAL and any unindexed WAL that lies between the lowest and highest indexed WALs.
- RecoverLogFiles fails closed only for an unindexed WAL inside the indexed range, with "WAL X carries no WAL index but follows indexed WAL Y and precedes indexed WAL Z in a set written with wal_partitions > 1; the merge cannot order it". Unindexed WALs above the range set merge_until.
- ProcessLogFilesMerged keeps WALs at or above merge_until out of the merge and its expected-WAL set. After the merge's end-of-recovery checks, it replays them with ProcessLogFile and CheckSeqnoNotSetBackDuringRecovery, as a legacy prefix is replayed.
- A kNone opener cannot write spans, so it cannot attest the members it would retire. A recovered prepare whose WAL is a merged member above the lowest member is moved to the lowest member: its batch log number and logs_with_prep_tracker_ both move. The indexed set is then retired whole, and never with a hole.
Evidence:
- New GC26RollbackToNoneKeepsPrepare: an image written at N=2 or N=4, reopened with kNone while the prepare is outstanding, then crashed. Every mode opens with every acknowledged write and the prepare. The test asserts that the old WAL is kept.
- New GC26TrueAlternationFailsClosed: after that rollback, partitioning is turned back on while the prepare is still outstanding. The next open finds unindexed WALs between indexed ones, and every mode returns Corruption naming both WALs.
Neuters:
- The gate as at base (any unindexed WAL above the lowest indexed WAL): GC26RollbackToNoneKeepsPrepare fails with "carries no WAL index but follows indexed WAL 14 and precedes indexed WAL 20".
- No pin at the lowest member: the old WAL is deleted, and the test fails its assertion and then aborts.
- Treat alternation as a suffix: the merge still refuses the inner WAL by itself ("WAL 47 carries no WAL index ... an unindexed file cannot be ordered in the merge"), naming only that WAL, so the message check fails. True alternation therefore fails closed even without the gate. The gate decides before the merge and names both neighbours.
### Q4. Recovery modes follow D-10
Property, with a partition_wal_usage other than kNone:
- Skip skips an unexplained hole and applies every record above it, as skip does with one WAL for records it cannot read. It still never applies a record that an earlier recovery declared superseded.
- Tolerate and absolute refuse to open on a hole.
- Point-in-time opens the prefix below the hole.
How:
- WALIndexMerger::SetSkipUnexplainedHoles(true) is set only in kSkipAnyCorruptedRecords. When it is set, Next counts the hole (GetSkippedHoles, GetFirstSkippedHole) and moves on, instead of stopping at the frontier or at a final pristine hole. The lost_floor_ stop does not apply in skip mode, so the stream ends cleanly once every member is done.
- ProcessLogFilesMerged logs a warning with the number of skipped holes and drops the "kSkipAnyCorruptedRecords does not skip unexplained holes" clause from its frontier error.
- Docs: a paragraph for indexed sets on each WALRecoveryMode value, a recovery-modes paragraph in the wal_partitions doc, a sentence in the partition_wal_usage field doc, and the new release note unreleased_history/behavior_changes/partition_wal_recovery_modes.md.
Evidence:
- New GC26SkipModeSkipsUnexplainedHole covers N in {1, 2} with partition 0's middle WAL holding only t0, which is either torn mid-record or dropped at the start of its record. Skip applies every record above t0. Tolerate and absolute fail. Point-in-time opens the prefix below t0.
- New GC26SkipModeNeverAppliesSuperseded is a guard: under skip, n1 is applied and none of the superseded copies are. It passes at the base and under the neuter below. In this layout the supersession explains the lost index, so no hole is skipped.
- New LogMergeTest.SkipUnexplainedHolesEmitsAboveThem.
- Existing tests whose skip cell flips from Corruption to open (invariant 3 exceptions, required by D-10): TornTailsInSeveralPartitionsPerMode, MissingMidChainWalPerMode, DamagedPartitionWalHeadIsBoundedPerMode and FirstSessionBottomLossIsDetected now check the skip open with AssertSkipOpensCopy. GC23MissingCurrentIndexedWalAfterPrefix's skip cell is now kOk with 1 record. GC24LostCurrentWalBelowSurvivorIsAHole's skip cell opens and keeps "kept". SkipModeFailsOnPristineHoleAndSaysWhy is renamed SkipModeSkipsPristineHole. In db_wal_test, MixedVoidAndHoleMapsPerMode's skip cell opens with keys 0 to 4. PristineHoleFailsExceptPointInTime's skip cell still fails, now on the out-of-order index rather than on "unexplained hole".
Neuter:
- SetSkipUnexplainedHoles(false): GC26SkipModeSkipsUnexplainedHole fails with "unexplained hole at wal_index 3 with records above it; cannot bound". GC26SkipModeNeverAppliesSuperseded passes; it is a guard, not a reproduction.
### Q5. Ports, refusals, hooks, sanitizer
(a) GC24HistoryFloorScopeOnUpgrade, ported unmodified. It passes at the base, because it is test-only.
- Neuter: HeadBounded holds whenever no member attests a predecessor. The spans-off layouts then open, and the test fails (`s.IsCorruption()` is false).
(b) In DBImpl::ResumeImpl, when the flush reason is kErrorRecoveryRetryFlush, NumWalPartitions() > 1 and a burned index is pending (new DBImpl::BurnedWalIndicesPending()), Resume takes the full kErrorRecovery path, whose memtable switches rotate the WALs. GC24RetryFlushRecoveryWithBurnedIndexProgresses is ported with it. N=1 and the retry path with nothing burned are unchanged.
- Neuter: drop the override. Resume() fails with "Corruption: WAL recovery found no healthy WAL to explain burned WAL index 3".
(c) New GC26ColumnFamilyRefusalsHoldAfterOpen: at N>1, CreateColumnFamily and SetOptions refuse the same column-family options that DB::Open refuses. max_successive_merges is the one that can change at runtime. No code was needed: ColumnFamilyData::ValidateOptions already runs on both paths, so this test pins existing behaviour and has no neuter.
(d) The three dead `DBImpl::ValidateOptions:AllowWalPartitions` callbacks are removed:
- transaction_test.cc SyncPrepareAfterSyncCommitSurvivesCrash.
- transaction_test.cc FU14SnapshotRace::Open.
- db_write_test.cc FU14H6TornFirstRecordInBrandNewNTwoDb.
No sync point with that name exists at the base. The affected tests pass.
(e) In tools/db_crashtest.py finalize_and_sanitize, the N>1 branch that keeps partitioning now sets test_secondary = 0 and continuous_verification_interval = 0. A secondary refuses partitioned WALs, and continuous verification reads through one.
- Python check (scripts/check_sanitizer.py, uncommitted) runs finalize_and_sanitize over randomized parameter sets. On this commit, 1460 sets kept wal_partitions > 1 and none of them had either knob non-zero. On the base, all 1460 such sets violated. db_stress was not run (the doc's instruction).
## Fold-back split
For each hunk, the target is `git blame` at the base plus that commit's Differential Revision line.
- db/db_impl/db_impl_write.cc:
- CoverBurnedWALIndex push, ExplainBurnedWALIndices read-back/zero/sync block and the `landed` skip: GC21 lines (47da494) -> D123701876.
- BurnedWALIndexLanded and the `<unordered_set>` include: new code -> D123701876.
- db/db_impl/db_impl.h:
- BurnedWalIndex::wal_offset: GC21 struct -> D123701876. The struct otherwise comes from D123079329.
- Declarations of BurnedWALIndexLanded and BurnedWalIndicesPending: new code -> D123701876.
- Declarations of RecoveredWALIndexPredecessors and WriteFurtherWALIndexPredecessors, and the new parameters of ProcessLogFilesMerged and CheckWALFilesCarryWALIndex: next to D123928339's declarations -> D123928339.
- db/db_impl/db_impl.cc ResumeImpl override: new code next to upstream lines (meta#11903, D49693812). Per the doc, Q5 (b) goes to D123928339 / D123701876; it goes to D123701876, where the burned-index explanation lives.
- db/db_impl/db_impl_open.cc:
- CheckWALFilesCarryWALIndex outputs and the RecoverLogFiles gate and merge_until: D123928339 lines -> D123928339.
- ProcessLogFilesMerged suffix collection, expected-WAL exclusion, suffix replay and the kNone prepare pin: new code next to D123928339's prefix handling -> D123928339.
- ProcessLogFilesMerged SetSkipUnexplainedHoles, skipped-holes warning, the removed skip clause and the WALRecoveryMode comment: D120649665 lines -> D120649665.
- RecoveredWALIndexPredecessor(s), WriteFurtherWALIndexPredecessors and its call in Open: D123928339 lines -> D123928339.
- db/log_merge.h and db/log_merge.cc:
- AttestedSpans, the ReaderMember override and ComputeLowerBound folding over every span: D120624825 lines -> D120624825.
- Skip-hole members, setters and getters, and the Next changes: D120624825 lines, with D120649665 lines at the frontier -> D120649665 (merge-driven recovery modes).
- db/log_reader.h and db/log_reader.cc: further-span decode, getter and member: D120621828 lines -> D120621828.
- include/rocksdb/options.h:
- WALRecoveryMode paragraphs: new text inside upstream docs (D4519996, D23169075) -> D120649665, whose behaviour they document.
- wal_partitions paragraph: GC18 / D117251769 text -> D117251769.
- partition_wal_usage sentence: D118367634 -> D118367634.
- unreleased_history/behavior_changes/partition_wal_recovery_modes.md: new code -> D120649665.
- tools/db_crashtest.py: D126533194 lines -> D126533194.
- Tests:
- Q1 tests and FailingWalFS::Landing -> D123701876.
- Q2 and Q3 tests, the DBWalPrepareAcrossChangeTest fixture, log_test and log_merge_test FurtherSpan tests, and ReopenWithChangedPartitionsWritesSpans -> D123928339.
- Q4 tests, AssertSkipOpensCopy, the updated skip cells and the log_merge_test skip test -> D120649665.
- Q5 (a) port -> D120649665. Q5 (b) port -> D123701876. Q5 (c) -> D123079329, which adds the refusals it pins (ColumnFamilyData::ValidateOptions).
- Q5 (d) hook removal: lines from the FU14 repro commits (9af6c88, fbea767, 2170735). Per the doc these fold with the GC18 flip, which stands alone.
## Assumptions
1. The base carries no GC26 repro tests, so the new tests are the evidence. Each was run against the base code, where the API allowed it. GC26PartitionReductionKeepsPrepare, GC26RollbackToNoneKeepsPrepare, GC26TrueAlternationFailsClosed, both Q1 tests, GC26SkipModeSkipsUnexplainedHole and GC24RetryFlushRecoveryWithBurnedIndexProgresses fail at the base. GC26SkipModeNeverAppliesSuperseded, GC24HistoryFloorScopeOnUpgrade and GC26ColumnFamilyRefusalsHoldAfterOpen pass there.
2. Q2: several ascending spans per head, using the existing span record. The reader rule is relaxed only for strictly ascending order. This adds no record type and no format change. The cost is one control record per extra folded chain, and only on an Open that lowers N.
3. Q2/Q3: a kNone opener cannot attest, so a prepare recovered from a merged member pins the lowest member. That choice is fail-closed and the least code. The alternative, a span-like record written by a kNone opener, would be a format change.
4. Q1: the torn copy is zeroed, not truncated. Posix FileSystem::Truncate is unsupported, and truncating through a reopened writable file broke the MANIFEST synced-size check ("Size mismatch"). A file system without NewRandomRWFile fails Resume, which is fail-closed.
5. Q1: the burned record's offset is the writer's flushed size when the failure is recorded. The failure poisons the writer, so only the failed record and the progress record from Resume's rotation can follow it.
6. Q1: a landed record is replayed. Its column family has usually been flushed past the WAL by Resume's flush, so the value is already in an SST or, for the failed key itself, absent (the test expects NOT_FOUND there, as D-1 allows either).
7. Q3: re-enabling partitioning while a prepare from before the rollback is outstanding produces true alternation, which fails closed per D-GC25c.
8. Q2: the further spans share the first span's sync point (DBImpl::StartWALFile:WriteSpan), so tests that turn spans off turn off all of them.
9. Invariant 3/4 exceptions: the existing tests listed under Q2 and Q4 encoded the old behaviour that D-GC25b and D-10 change. Only their expectations changed.
## Not done
- A kNone opener's own point-in-time cut cannot be declared, because it writes no index records. Its later sequential suffix replays in file order, as before. This predates this change.
- db_stress was not run (the doc's instruction for Q5 (e)).
## Test plan
All commands run from the clone with TEST_TMPDIR=~/pwal-3p/gc-26-claude-tmp, at most 83 jobs (166 cores). The home volume is shared and filled up during the session. Runs that hit ENOSPC were discarded and rerun with fewer workers; see each item.
1. Debug suites. `make -j60` of the 11 binaries, then `python3 build_tools/gtest-parallel -w 32` over db_write_test, db_wal_test, log_merge_test, log_test, db_wal_oracle_test, transaction_test, write_prepared_transaction_test, db_secondary_test, db_basic_test, db_options_test and error_handler_fs_test. Result: 8062/8062 passed (0 failed), on binaries rebuilt after the last source edit. An earlier full run, before the last two db_wal_test skip-cell updates, failed only those two tests; GateSyncToleratesCoupledRotation flaked once in a different earlier run (see item 9).
2. Repeats, 100x, `gtest-parallel -r 100` (debug binaries; 4 to 16 workers, because each N=8 test DB preallocates about 560M of WAL):
- db_write_test, the SyncPoint-driven or fault-injection new or changed tests: GC26ResumeExplainsOnlyWhatDidNotLand, GC26ResumeFailsWhenBurnedIndexReadBackFails, GC24RetryFlushRecoveryWithBurnedIndexProgresses, GC24HistoryFloorScopeOnUpgrade, FU14H6TornFirstRecordInBrandNewNTwoDb (hook removed) and GC26TrueAlternationFailsClosed (FailingWalFS). Result: 600/600 passed.
- transaction_test, the tests whose hook was removed: SyncPrepareAfterSyncCommitSurvivesCrash and every test that uses FU14SnapshotRace (FU14TimestampedSnapshotListStaysSorted, FU14TimestampedSnapshotSurvivesCompaction, GC22TimestampedSnapshotReservedBeforePublish, GC22TimestampedSnapshotsOutOfSequenceOrder, GC23SnapshotReservationInProperties, GC23TimestampedSnapshotsSurviveFlushStress). Result: 700/700 passed.
- log_merge_test *FurtherSpan* and *SkipUnexplainedHoles*: 800/800. log_test *WALIndexFurtherPredecessorSpansAscend* and *WALIndexSecondPredecessorSpanReportsCorruption*: 800/800.
- An earlier attempt at 16 to 40 workers filled the shared home volume (ENOSPC). It was stopped and discarded; none of its results are counted.
3. TSan: `USE_CLANG=1 COMPILE_WITH_TSAN=1 make db_write_test db_wal_test log_merge_test log_test transaction_test` (clang 22.1.3), built in a copy of the tree under -tmp so the clone's debug objects stayed in place. Every changed file in the copy was checked byte-identical to the commit. TSAN_OPTIONS=halt_on_error=1, run over every new or changed test:
- db_write_test (every new or changed test, FU14H6 included): 24/24 instances.
- db_wal_test MixedVoidAndHoleMapsPerMode and PristineHoleFailsExceptPointInTime: 2/2.
- log_merge_test: 8/8. log_test: 8/8.
- transaction_test, the 7 tests above: 7/7.
- 0 ThreadSanitizer reports. A first TSan run hit ENOSPC in 7 db_write_test tests; it was discarded and rerun.
4. Neuters (scripts/neuter.py and run_neuters.sh, uncommitted). Each neuter is an exact-match patch of the working tree; the script checks that the file's SHA-256 changed and runs make, then the test. The file is restored with copyfile plus a fresh mtime, and a final rebuild follows. After all neuters, the tree's diff hash matched its value before them. Results are listed under each question. Every neuter listed fails as stated, except the Q4 guard, which is described as passing.
5. GC15 oracle: `ROCKSDB_WAL_ORACLE_CYCLES=300 ./db_wal_oracle_test --gtest_filter=DBWalOracleTest.RecoveredStateIsPrefixOfHistory`, with ROCKSDB_WAL_ORACLE_SEED in 20261029, 20261329, 20261629 and 20261929, run in parallel, so seeds 20261029 to 20262228. Result: 1200 cycles, 0 violations, all 4 runs OK. N=2 in 609 cycles and N=8 in 591; power loss in 642, losing an acknowledged write in 450; 148 recoveries stopped at a cross-partition hole.
6. N=1 byte identity. Release db_bench (`DEBUG_LEVEL=0`), base binary from the -base worktree at 121a5a0, and this change built in a copy of the tree that differs from the commit only in test files db_bench does not build, run back to back 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 new binary contains this change's log string ("it is recovered, not voided"); the base binary does not.
7. 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 (one db_wal_test.cc assertion was rewrapped).
- After committing: `FORMAT_UPSTREAM=121a5a077 make check-format`: "Nothing needs to be reformatted!"
- `make check-sources`: passes.
8. Q5 (e): `python3 scripts/check_sanitizer.py tools/db_crashtest.py tools <dir>` (uncommitted). It runs finalize_and_sanitize on 2000 randomized parameter sets with test_secondary=1 and continuous_verification_interval=1000 forced on and wal_partitions in {2, 4, 8}, and counts sets that keep N>1 with either knob non-zero. Four runs each (db_crashtest seeds its own RNG at import, so the kept count varies between 1000 and 1460 per run). This commit: 0 violations in every run. Base (`git show 121a5a0:tools/db_crashtest.py`): every kept set violates. db_stress was not run.
9. Pre-existing flake: DBWritePartitionTest.GateSyncToleratesCoupledRotation fails intermittently under load with `rotated_at < sync_finished_at` (3 vs 2). 100x repeats: 4/200 failed at this change and 2/200 at the base (base worktree rebuilt at 121a5a0), same assertion. This change does not touch it.
10. Base runs of the new tests (Assumption 1): the new test file compiled against the base in the -base worktree, with the one missing test API stubbed. Results are listed under Assumption 1. The worktree was then restored to 121a5a0 and rebuilt.
Recovery triggers flushes for very different scenarios:
(1)
FlushReason::kErrorRecoveryRetryFlush: a flush failed(2)
FlushReason::kErrorRecovery: a WAL may be corrupted(3)
FlushReason::kCatchUpAfterErrorRecovery: immutable memtables may have accumulatedThe old code called called
FlushAllColumnFamilies()in all cases, which uses manual flush functions:AtomicFlushMemTables()andFlushMemTable(). Forcing flushing the latest data on all CFs was useful for (2) because it ensures all CFs move past the corrupted WAL.However, those code paths were overkill for (1) and (3), where only already-immutable memtables need to be flushed. There were conditionals to exclude some of the extraneous logic but I found there was still too much happening. For example, both of the manual flush functions enter the write thread. Entering the write thread is inconvenient because then we can't allow stalled writes to wait on a retrying flush to finish.
Instead of continuing down the path of adding more conditionals to the manual flush functions, this PR introduces a dedicated function for cases (1) and (3):
RetryFlushesForErrorRecovery(). Also I cleaned up the manual flush functions to remove existing conditionals for these cases as they're no longer needed.