Repository navigation
[GC] GC18: Lift the N>1 gate for indexed WALs; fence failed gate syncs - #8
Closed
JustinGaoF wants to merge 1 commit into
Closed
JustinGaoF wants to merge 1 commit into
JustinGaoF wants to merge 1 commit into
Conversation
[GC] GC18 -- Indexed N>1 opens in production builds (G-01, G-63) Reviewer question: With every gate item closed, does indexed N>1 now open in production, does everything else stay rejected, and do the docs tell an operator how to roll it out safely? Short answer: yes. DB::Open accepts wal_partitions > 1 with an indexing partition_wal_usage, with no sync point and no opt-in, in release and debug builds. kNone + N>1 and every other M1.4 rejection still fail with their exact Status. The wal_partitions doc comment and a new release note give the rules, the rejected options, and the rollout order (readers first). The GC13 opt-in is removed (D-G18k = (i)). The carry-over is done too: Q8 fix (a sync write whose gate fsync fails stays invisible), plus Q6, Q7, Q9, Q10 and Q11. Out of scope / open gate rows: none. The stack owner confirmed every Gate items row, or deferred it with a reason, before dispatch (table below). No row is open, and nothing here fixes a gate item except Q8, which the user ruled on 2026-10-26. Decision: D-G18k = (i), remove the opt-in (the dispatcher's choice). The option `experimental_allow_wal_partitions_for_testing`, its OPTIONS-map entry, Dump line and generated C accessors are deleted. db_bench, db_stress and test::SetWalPartitions stop setting it. The debug sync point `DBImpl::ValidateOptions:AllowWalPartitions` is deleted with the gate, and all 20 uses in the 6 files are removed. ## Q5 -- Gate items (copied as the stack owner filled them in) | Gate | What "closed" means | Confirmed by user (date) | |---|---|---| | GC01-GC17 | Each round's winning diff is accepted and in the base chain. Every checklist item those docs list is closed, or explicitly deferred by the user with a reason. | Confirmed 2026-10-27: all accepted and folded at M3 (pwal/m3 @ a855854, 9311/9311 tests); open items deferred as listed below the table | | Sec.2 visibility, durability, failure (G-10, N-2-1, G-12-G-16, N-2-3-N-2-5, N-7-1, CDR-F004) | Closed per the checklist done-whens. | Confirmed 2026-10-27 (G-10: GC07 + GC08; CDR-F004: GC03 + GC13; the rest by GC07-GC09) | | Sec.4 recovery (G-20-G-29, N-4-x, CDR-F002, F006, F007, F017) | Closed, or decided and amended (D-G24, D-G25, D-G26). | Confirmed 2026-10-27 (GC01, GC02, GC11; D-G24/25/26 settled by GC11) | | Sec.5 consumers (G-30-G-38, N-5-x, CDR-F005) | Every consumer merges or rejects N>1. Checkpoint and backup copy all N chains. | Confirmed 2026-10-27 (GC12, GC14a, GC14b); G-35's ingestion-stall histogram, G-36's public WalFile partition accessor and G-37 deferred | | Sec.7 evidence (G-50-G-57) | Tools, histograms, latency FS, oracle, benchmarks, N>1 coverage all landed. The GC16 abandon trigger did not fire, or the user accepted it. | Confirmed 2026-10-27 (GC13, GC15, GC16, GC14a, GC14b); trigger 0.0021-0.0026 at M3, does not fire | | G-60 | T0.3 maintainer sign-off recorded, or the out-of-band sign-off linked (Design:2544-2545; Tasks:134). | Deferred by the user 2026-10-27 (for the land decision) | | G-33 | The replication-contract decision is recorded in Execution.md (Design M4.2/T6.1). | Deferred by the user 2026-10-27; GetUpdatesSince stays NotSupported at N>1 (D-G32 (a)) | | Fleet rollout (R-1/R-2, hard rule 4) | A reader-capable binary is deployed everywhere WALs are read before any writer enables indexing. This is not code; the user owns it. | Deferred by the user 2026-10-27 (user-owned; before any production writer enables indexing) | | All Sec.0 decisions | Each is settled, and its unchosen option struck in the doc that used it. | Confirmed 2026-10-27 (decision tracker); D-G18k = (i); D-G37 deferred with G-37 | Deferred by the user (2026-10-27), with the reason "not required for the testing-stage flip; tracked for the land decision": - G-19a (WAL-index allocation takes a global mutex; GC17 Q2 Not done) - G-37 / D-G37 (sequence-floor retention; the stack keeps coupled rotation) - G-62 (P1 cannot land alone) - G-35's ingestion-stall histogram - G-36's public WalFile partition accessor - G-60 - G-33 - fleet rollout - the doc-only items: G-09 doc part / S-18, N-6-2, N-7-2, and the S-xx edits Checklist IDs per question: - Q1: G-01 (the gate lifts for indexed N>1); M3 "N>1 production-testable". - Q2: G-01 and G-02 (permanent kNone rejection); G-07 (M1.5 matrix, hook-free); N-1-1 (upper bound). - Q3: G-01; S-17, code half (option doc and release note). - Q4: D-G18k = (i); D-G51 (opt-in removed); G-01 (no hook needed). - Q5: G-63 (M3 reached, gate table recorded). - Q6: G-55 follow-up (GC14a carry-over). - Q7: G-30 residual follow-up (GC14a carry-over). - Q8: GC17 carry-over, user ruling 2026-10-26 (GC17 Assumption 1 closed). - Q9: GC17 carry-over, user ruling 2026-10-26 (per-partition fsync wait pinned). - Q10: GC17 carry-over (test gaps; G-14 regression guards). - Q11: GC17 carry-over (sync-point names). ## Answers ### Q1 -- Indexed N>1 opens in a production build without hook or opt-in [G-01] Property: DB::Open accepts WALIndexEnabled(partition_wal_usage) && wal_partitions > 1 when no other rejection applies. Default wal_partitions stays 1. OpenForReadOnly, secondary and the other open paths run the same ValidateOptions as at the base, so GC12's N>1 behaviour is unchanged (secondary and RepairDB still refuse partitioned WALs; DBWritePartitionTest.ReadOnlyAndSecondaryApplyPartitionChecks and ReadOnlyCompactedOpenAppliesPartitionChecks still pass, now hook-free). How: db/db_impl/db_impl_open.cc deletes the gate block (the `DBImpl::ValidateOptions:AllowWalPartitions` sync point and the opt-in check). The kNone check that followed it stays; only its comment changes. The M1.4 matrix comment is rewritten for the new legality. Evidence: new file db/db_wal_partitions_open_test.cc, DBWalPartitionsOpenTest.IndexedOpensWithoutHookAndRecoversPrefix/{0,1}. It uses no sync point and nothing from the debug-only test harness, so it builds in release. Setup: indexed N=4, 8 column families, 200 writes with every fifth sync=true, at least 2 non-empty WALs asserted. - /1 (crash): Close, then FaultInjectionTestEnv::DropUnsyncedFileData, then reopen. Every write through the last sync=true one is present, and the recovered set is a prefix of write order. - /0 (clean close): recovers all 200. Passes 20x in release (DEBUG_LEVEL=0), 100x in debug and 100x under TSan. Neuter: restore the gate block. Open fails with "NotSupported: wal_partitions > 1 is not supported yet (for any partition_wal_usage)" in both variants (run in release). Extra neuter: the original FaultInjectionTestFS version of this test passed even with the gate fsync deleted, because unsynced data was not dropped on this path. So the test uses FaultInjectionTestEnv, and with the gate-time sync skipped the crash variant fails (a write above a hole comes back). ### Q2 -- The permanent rejections still hold [G-01, G-02, G-07, N-1-1] Property: kNone + N>1 is rejected with NotSupported("wal_partitions > 1 requires partition_wal_usage other than kNone"), naming both options. Every other N>1 rejection is unchanged. Exactly one check was removed: the gate. Evidence, all hook-free: - DBOptionsTest.WalPartitionsUsageMatrix: (kNone,1), (indexed,1) and (indexed,4) open; (kNone,4) returns the exact NotSupported string. - DBOptionsTest.SetDBOptionsRejectsPartitionWALUsage: unchanged; it still rejects both options. - DBOptionsTest.IllegalWalPartitionsPairInOptionsFileFailsOpen: an OPTIONS file with (kNone,4) fails Open naming both options; (indexed,4) opens. - DBOptionsTest.WalPartitionsValidation: N=4 with the default kNone gets the kNone message. - DBWriteTestUnparameterized: UnindexedWalPartitionsAlwaysRejected, WalPartitionsUpperBound (65 is InvalidArgument; 64 opens), WalPartitionsRequireParanoidChecks, and WalPartitionsRejectionsNameTheirOptions (every M1.4 rejection, each message naming its option). - DBWritePartitionTest: MemtableDecisionEnforcedAtOpen, ConcurrentUnsafeConfigsRejectedAtOpen, RejectsPipelinedWalPartitions, RejectsSeqPerBatchTwoQueues. Neuter: drop the kNone check. WalPartitionsUsageMatrix, WalPartitionsValidation, IllegalWalPartitionsPairInOptionsFileFailsOpen and UnindexedWalPartitionsAlwaysRejected fail ((kNone,4) opens). Invariant 4: tests that asserted NotSupported for indexed N>1 without the hook now assert that it opens: - WalPartitionsUsageMatrix, cell (indexed,4). - IllegalWalPartitionsPairInOptionsFileFailsOpen, indexed iteration. - LdbCmdWalPartitionsTest.DumpWalAtWalPartitions/WalPartitions8: `dump_live_files` now succeeds and lists every partition's current WAL. ldb opens from the OPTIONS file, which keeps wal_partitions and the indexing usage. - DBWriteTestUnparameterized.WalPartitionsTestingOptIn, renamed to IndexedWalPartitionsOpenFromOptionsFile: it opened with the opt-in and asserted that a reopen from the OPTIONS file was refused. Now both open and read back the data. - WalPartitionsValidation: its message changed from the gate's to kNone's. Each follows directly from the lifted gate. No other expectation changed. ### Q3 -- The option doc and release note describe the shipped behaviour [G-01, S-17] include/rocksdb/options.h, wal_partitions (final text): // EXPERIMENTAL // // The number of WAL files ("partitions") that writes are spread across. // // A single WAL file admits only one append in flight at a time, because // durability granularity is per file descriptor. On storage where append // latency is high relative to bandwidth, that single outstanding I/O bounds // write throughput no matter how fast the device is. Spreading writes over N // WAL files allows N concurrent appends. Recovery merges the partitions back // into a single stream ordered by the WAL index that partition_wal_usage // records, so the logical log is unchanged. // // Values greater than 1 require a partition_wal_usage other than kNone, // which records the order recovery needs to merge the partitions; // partition_wal_usage = kNone with wal_partitions > 1 is rejected at Open() // with Status::NotSupported. Values above 64 are rejected with // Status::InvalidArgument. With more than one partition, Open() also rejects // two_write_queues, enable_pipelined_write, unordered_write, // track_and_verify_wals, recycle_log_file_num > 0, // allow_concurrent_memtable_write = false, paranoid_checks = false, // track_and_verify_wals_in_manifest = false, and, per column family, // inplace_update_support, enable_blob_direct_write, max_successive_merges > 0 // and any memtable other than the skip list, as well as // OptimisticTransactionDB with serial validation; each message names the // conflicting option. WriteWithCallback() with a callback, // WriteBatchWithIndex ingestion and GetUpdatesSince() return // Status::NotSupported. With the default of 1 the WAL is byte-for-byte // identical to a build without this option. // // manual_wal_flush is supported but not recommended with more than one // partition: FlushWAL() flushes every partition's buffer while holding every // partition's WAL write lock, which re-imposes the coordinated flushing that // partitions exist to avoid. // // Enabling more than one partition is a rollout step: every binary that may // read these WAL files (the DB itself on reopen or rollback, ldb, backup and // checkpoint restore, RepairDB, secondary instances) must first be upgraded // to one that understands partitioned, indexed WALs, before any DB is // opened with wal_partitions > 1. Secondary instances and RepairDB refuse // partitioned WAL files with Status::NotSupported. // // Not dynamically changeable via SetOptions(). // // Default: 1 uint32_t wal_partitions = 1; unreleased_history/new_features/wal_partitions.md (new): `DBOptions::wal_partitions` values above 1 are now accepted (EXPERIMENTAL). Writes are spread across that many WAL files so that appends to them proceed concurrently; recovery merges them back into one ordered log. It requires `partition_wal_usage` other than `kNone` (the combination with `kNone` is rejected), is limited to 64, cannot be changed with `SetOptions()`, and is rejected together with the options listed in its documentation (for example `two_write_queues`, `enable_pipelined_write`, `unordered_write`, and `track_and_verify_wals_in_manifest = false`). Enabling it is a rollout step: first deploy a binary that understands partitioned, indexed WALs everywhere these WAL files may be read (the DB itself, ldb, backup and checkpoint restore, RepairDB, secondary instances), and only then open a DB with `wal_partitions > 1`. `manual_wal_flush` is supported but not recommended with more than one partition. partition_wal_usage's doc (D118367634) says nothing that contradicts this, so it is unchanged. Each option listed is enforced by a test named under Q2. Argued, not tested beyond that (docs). ### Q4 -- Tools and tests are off the hook and the opt-in [D-G18k = (i)] Removed: - The option: include/rocksdb/options.h, options/db_options.{h,cc} (type map, ctor, Dump), options/options_helper.cc, options/options_settable_test.cc. - Its generated C accessors: `make regen-c-api` (db/c.cc, include/rocksdb/c.h, c_api_gen/*.inc). Both removals are recorded in tools/c_api_gen/api_compatibility_allowlist.json with the reason (never released). - The setters: test::SetWalPartitions (test_util/testharness.cc), db_bench (assignment and flag help), db_stress (two assignments and the flag help), db_wal_oracle_test, latency_injection_fs_test. - Every debug-hook use, in db_write_test.cc (fixture helpers OpenWithPartitions/ReopenWithPartitions, the write_prepared fixture and the individual tests), ldb_cmd_test.cc, optimistic_transaction_test.cc, transaction_test.cc and write_prepared_transaction_test.cc. Each deleted hook callback only made the deleted gate pass. Removing it is behaviour-neutral for indexed N>1, because the gate no longer exists. Where a callback was the test's only reason to call EnableProcessing(), the call stays if later sync points in the test need it (OpenWithPartitions, ReopenWithPartitions, the WritePreparedPartitionedWal fixture, transaction_test's SnapshotCommitPublishesAboveHeldLowerWrite). Otherwise the call and its paired Disable/ClearAllCallBacks are removed. db_crashtest.py is unchanged: it never passed the opt-in (db_stress set it internally). Its N in {1,2,8,16} sweep now runs in a plain opt build. One db_stress fix the flip exposes: the LockWAL verification called GetCurrentWalFile(), which is NotSupported at N>1 (there is no single current WAL). The bb8 run failed on it with "GetCurrentWalFile() failed: Not implemented". At N>1 that one check is skipped; the seqno check still runs (db_stress_tool/db_stress_test_base.cc). Evidence: release db_stress from this commit, 180 s each: - blackbox N=8 indexed: exit 0, all 7 db_stress invocations at --wal_partitions=8; - whitebox N=8: exit 0 (one check_mode=0 db_stress run at --wal_partitions=8 --disable_wal=0, killed at its interval with exitcode -15, then the normal "running too long" stop at the duration; --enable_blob_direct_write=0 --best_efforts_recovery=0 pinned, see Assumption 9); - blackbox N=1 partition_by_column_family: exit 0. `git grep` finds no `experimental_allow_wal_partitions` and no `AllowWalPartitions`. ### Q5 -- M3 reached [G-63] See the gate table and the per-question checklist lines above. ### Q6 -- WritePrepared 2PC with the commit marker on another partition recovers atomically [G-55] Ported from GC14a's Muse candidate (pwal/ab/gc14a-muse-PR5, 07dbcab); credit to it: WritePreparedTransactionTest. TwoPhaseCommitSpanningPartitionsRecoversAtomically plus its friend line in write_prepared_txn_db.h. Only those two pieces are ported (no db_filesnapshot.cc change). The test: at N in {2,8} it finds an XID whose CF-less commit marker routes to a different partition than the prepare (asserted through DBImpl::WriteToWAL:AppendOutcome). Then, in each of the 4 recovery modes, it crashes before or after the commit: - before: the prepared transaction is recovered and neither key is visible; - after: both keys are visible and no prepared transaction remains. Evidence: passes, 100x debug, 100x TSan: 100/100 debug and 100/100 TSan, no TSan report (every instance, including the 9 WritePreparedTransaction params). Neuter: recovery drops a commit marker read from a partition other than the prepare's. The crash-after cells fail at mode=1 (`xa` NotFound: the transaction comes back uncommitted). ### Q7 -- Flush-less backup racing LockWAL/UnlockWAL [G-30 residual] New test BackupEngineTest.BackupWithoutFlushRacingLockWAL (utilities/backup/backup_engine_test.cc), modelled on CheckpointRacingLockWAL; it runs in the WalPartitions8 instantiation among others. Writers run on every partition while a locker thread loops LockWAL/UnlockWAL, and 5 CreateNewBackup(flush_before_backup=false) calls each finish within RunWithin(30 s). Each backup is restored by ID and checked in every recovery mode: it opens and holds a per-writer prefix that includes every write acknowledged before the backup. A 1 ms sleep at CheckpointImpl::CreateCustomCheckpoint:AfterGetLive1 widens the race window. Without it the neuter did not fail in 40 runs. Evidence: 200 repeats of the N=8 case = 1000 backups, 0 unopenable or non-prefix copies. Re-run at the final commit: WalPartitions8 case 100/100 debug (500 backups) and 100/100 TSan (500 backups), 0 unopenable or non-prefix copies. Neuter: restore the pre-GC14a skip-then-read order in GetLiveFilesStorageInfoImpl (no pinned LockWAL count). 3 of 40 runs (200 backups) fail with an unopenable or non-prefix restore. ### Q8 -- A sync write whose gate fsync fails stays invisible [GC17 carry-over; fix] Before: at N>1 a sync write is inserted and published before its gate fsync. When that fsync failed, the write returned IOError, but its records could be published, and after Resume() flushed and kept. Now a failed gate sync is handled like a failed append: - RunCoalescedGateSync(low, target, ...) calls FenceFailedGateSync(low) when its sync() fails, before any coalesced waiter may start its own sync. FenceFailedGateSync installs a gate fence at the group's first sequence, using the background error that the sync's WALIOStatusCheck raised, with released_by_recovery = true. - PublishAppliedFrontierLocked (factored out of PublishAppliedPrefix) never publishes into an open fence. A failed append or insert leaves its range unapplied anyway; a failed gate sync fences a range that has already applied. - Recovery's flush drops entries at or above the fence (the existing DropEntriesAtOrAbove), and every gate in the fence returns the error. - ClearWalDurabilityBGError republishes the frontier only when it closed such a fence. - The low bound is threaded through RunCompletionGate and both gate lambdas (WriteImpl: current_sequence; WriteImplWALOnly: last_sequence + 1). - Both gate syncs fence on failure: the first one and the manual-flush/post-wait one. - Coalesced waiters retry their own sync. One above the failed write hits the fence and returns the background error. One whose own sync fails fences itself. N=1 is unchanged: all of this is under NumWalPartitions() > 1, and N=1 WAL bytes match the base (below). Evidence: DBWritePartitionTest.FailedGateSyncWriteStaysInvisible (N in {2,8}). - Phase 1: async write A is held before its append, then sync write B's gate sync fails with a retryable IOError. Get(B) is NotFound before Resume(), after Resume() plus Flush, and after a reopen in each of the 4 recovery modes. Every acknowledged write below B is present each time. - Phase 2: concurrent sync writes C and D coalesce while lower write A2 is held, and the sync fails. Same checks: C and D are absent and A2's lower writes are present. 100x debug, 100x TSan: 100/100 debug and 100/100 TSan, no TSan report (both N). Neuter: skip FenceFailedGateSync. key_b becomes visible ("value_b") after Resume() plus Flush. Changed by design (this ruling): GatePostWaitSyncFailureWakesParkedGate. Parked writer W now fails at B's fence, so it may park once or twice (error wake, then fence wake; TSan scheduling shows the second), and it returns. The test asserts w_parks in [1,2], no waiters, w_returned. ### Q9 -- An async append's wait for its own partition's fsync is pinned [GC17 carry-over] Ported from GC17's Muse candidate (pwal/ab/gc17-muse-PR7, 110e488); credit to it: the sync point `DBImpl::SyncWalPartitionFiles:BeforeSyncPartition` (fires per partition under that partition's mutex, db/db_impl/db_impl.cc) and AsyncAboveSyncReturnsWhileSyncFsyncHeld. New q-variant: AsyncOnSyncingPartitionWaitsForItsFsync. - With a sync write held inside partition q's fsync, an async write on partition r completes within RunWithin. - An async write on q blocks: the test detects that it has joined, via WriteThread::JoinBatchGroup:Start, then sees it still pending after 100 ms. It completes once q's fsync is released. 100x debug, 100x TSan: 100/100 debug and 100/100 TSan, no TSan report (both tests, both params). Neuter: hold every partition's WAL mutex across the whole multi-partition fsync. The r-write does not finish and RunWithin aborts after 30 s. ### Q10 -- GC17's test gaps [GC17 carry-over] - GateSyncToleratesCoupledRotation (ported from GC17's Muse candidate; credit) replaces the vacuous LeadershipSyncExcludesCoupledRotation. A coupled rotation inside the gate-sync window leaves the partition deques consistent, and a second sync write succeeds. - PartialGateSyncCutLosesHigherAsyncWrite (ported from GC17's Muse candidate; credit). After a partial gate-sync failure and a crash, the default mode fails closed and point-in-time recovery recovers a prefix. - CoalescedGateSyncsFsyncEachPartitionOnce (new). Concurrent sync writes on several partitions queue at RunCoalescedGateSync:BeforeWait (new sync point). Each is acknowledged only after every partition has synced through its sequence. Exactly 2 fsyncs per partition happen: the leader's round and one coalesced round for all waiters. A crash then keeps every acknowledged write. Neuter: the coalescer skips the last partition. q3 is NOT_FOUND after the crash. - WriteAdmittedByRecoveryAllocatesAboveFences (GC17's Q7 test) now asserts, at ErrorHandler::ClearBGError:BeforeClearStopped through TEST_WalGateFences() (ported accessor; credit GC17's Muse candidate), that the fences are non-empty and closed. The writer waits by retry, not a fixed sleep. Neuters: drop GC08's fence creation, and fences_at_hold is empty; swap ClearBGError's two steps, and a fence is still open at the hold. - ManualWalFlushSyncWriteSurvivesCrash (new). With manual_wal_flush, sync writes at N>1 survive a crash that drops unsynced data. Neuter: skip the gate sync, and an acknowledged sync write is lost. - The two GC17 crash tests, SyncWriteAboveAsyncWriteSurvivesCrash and AckedAsyncWriteAboveUnsyncedHoleIsCut, with neuters actually run: - skipping the gate-time sync makes SyncWriteAboveAsyncWriteSurvivesCrash (and SyncWriteMakesPrior..., ManualWalFlushSyncWriteSurvivesCrash and the Q1 crash test) fail; - explaining every hole (no cut) makes AckedAsyncWriteAboveUnsyncedHoleIsCut fail (C present). The doc's "sync moved back before insert" neuter does not fail them: a leader-time sync also covers the lower write. Argued, so the two neuters above stand in for it. - CommitOfDelayedPrepared at N=8: 100x debug 100/100 (CommitOfDelayedPrepared and NonAtomicCommitOfDelayedPrepared), 100x TSan 100/100, no TSan report. - Every test above: 100x debug and TSan clean: 100/100 debug and 100/100 TSan, no TSan report. ### Q11 -- Sync-point names match the gate-time sync [GC17 carry-over] Renames (no behaviour change): - DBImpl::PreprocessWrite:TakesSyncMarkMutex -> DBImpl::SyncWalsFromCompletionGate:TakesSyncMarkMutex - DBImpl::WriteGroupToWAL:TakesPartitionSyncMutex -> DBImpl::SyncEveryWalPartition:TakesPartitionSyncMutex - DBImpl::WriteGroupToWAL:AfterLeadershipSync, at the gate site -> DBImpl::SyncWalsFromCompletionGate:AfterGateSync The N=1 leader-time site keeps `DBImpl::WriteGroupToWAL:AfterLeadershipSync`, where it really fires (db_wal_test uses it). - Tests and the oracle (trigger kGateSync / "gate_sync") use the new names. `git grep` finds no old name at a gate-time site. - LeadershipSyncFailureWakesParkedGate is renamed GateSyncFailureWakesParkedGate (gate_sync wording). - The SyncWriteSyncsAgainOnlyAfterWait comments describe gate-time sync. Each renamed point's tests pass, and they fail under their neuters (GateSyncFailureWakesParkedGate, the N1/N2 lock-order tests, the Q9/Q10 tests above). Argued behaviour-neutral. ## Fold-back split Adding diffs come from `git blame` at a855854 plus each commit's `Differential Revision:` line. a855854 itself has no such line; the doc names it D127837663. None of its lines are modified here. Flip (Q1-Q5): stays the standalone diff on top, never folded. - db/db_impl/db_impl_open.cc - gate block :422-439: D123079329 (10 lines), D123928339 (6), D117251769 (2); - kNone comment :443 and M1.4 matrix comment :299-319: D117251769. - include/rocksdb/options.h: wal_partitions doc and opt-in field, D117251769. - options/db_options.{h,cc}, options/options_helper.cc, options/options_settable_test.cc: D117251769. - db/c.cc, include/rocksdb/c.h, c_api_gen/*.inc: regenerated (generator output for the D117251769 field). - tools/c_api_gen/api_compatibility_allowlist.json: new entries. - tools/db_bench_tool.cc, db_stress_tool/db_stress_gflags.cc, db_stress_tool/db_stress_test_base.cc :4683 and :7187: D117251769. (The doc expected D118371518; blame says D117251769.) - db_stress_tool/db_stress_test_base.cc :2632 (GetCurrentWalFile check): upstream code; part of the flip. - test_util/testharness.cc: D127275775. - db/db_options_test.cc: D117251769 (one line D123928339). - tools/ldb_cmd_test.cc: D127093323 (DumpWalOnPartitionedWals) and D127275775 (DumpWalAtWalPartitions). - utilities/transactions/optimistic_transaction_test.cc: D123079329. - utilities/transactions/transaction_test.cc: D123971668, D123928339 and D123701876 (hook removal per test). - utilities/transactions/write_prepared_transaction_test.cc :4716 (fixture hook): D123079329. - utilities/latency_injection_fs_test.cc and db/db_wal_oracle_test.cc (opt-in line): D126533193. - db/db_write_test.cc hook and opt-in removal, and the WalPartitionsTestingOptIn -> IndexedWalPartitionsOpenFromOptionsFile rewrite: the diffs that added each test (D117251769 for the unparameterized tests, D123079329 and later for the fixture). - New test file db/db_wal_partitions_open_test.cc, with its Makefile, src.mk, CMakeLists.txt and BUCK lines: new code, flip. - unreleased_history/new_features/wal_partitions.md: new, flip. Q8 -> D123701876, with a flag. - The code modifies: - the gate lambdas and RunCoalescedGateSync: D123551605; - PublishAppliedPrefix: D123476301; - ClearWalDurabilityBGError and UnreleasedWalGateFenceLow: D123701876; - RunCompletionGate: D123551605 / D123701876; - db_impl.h declarations at the same diffs. - FLAG: none of it compiles below D123701876, where InstallWalGateFence, the fence set and released_by_recovery first exist. So all Q8 code goes to D123701876 (the lowest diff where it compiles), not to D123551605. - FLAG: its test FailedGateSyncWriteStaysInvisible uses ReopenWithPartitions (D123928339), so the test can only live at D123928339. - GatePostWaitSyncFailureWakesParkedGate (changed by design): D123701876. Q6 -> D127275775: the write_prepared_transaction_test.cc test and the write_prepared_txn_db.h friend line (blame: upstream neighbours; new code). Q7 -> D127275775: backup_engine_test.cc, new test (neighbour from D127275775). Q9 -> D123971668: the sync point in SyncWalPartitionFiles. The two tests reopen with partitions: D123928339 or above. The tests use ReopenWithPartitions, so they go to D123971668 together with the sync point. Q10: - GateSyncToleratesCoupledRotation (replaces LeadershipSyncExcludesCoupledRotation; blame D126533193). The doc's map says D123928339; FLAG: it uses the D123971668 sync point, so it goes to D123971668 or its blamed D126533193. - PartialGateSyncCutLosesHigherAsyncWrite, CoalescedGateSyncsFsyncEachPartitionOnce (with the RunCoalescedGateSync:BeforeWait sync point, code from D123551605) and ManualWalFlushSyncWriteSurvivesCrash: D123971668 (they use the reopen helpers and the per-partition sync point). - TEST_WalGateFences() accessor: D123701876. - WriteAdmittedByRecoveryAllocatesAboveFences: D123928339. Q11: - The sync-point renames in SyncWalsFromCompletionGate and SyncEveryWalPartition: D123551605. - The test and comment updates in db_write_test.cc: the diffs that added each test (D123551605 / D123701876 / D123928339). - db_wal_oracle_test.cc trigger rename: D126533193. ## Assumptions 1. Q8 vs. publish-before-fsync (D-G11 (c), Q9, GC17's AsyncWriteDoesNotWaitForOtherPartitionsSync). A sync write may already be visible when its fsync fails, so "never visible" holds from the failure on. If a reader saw the write before the failure, the write is dropped at Resume() together with any acknowledged async writes above it, since they sit above an unsynced hole, as for a failed append. Rule: the doc's "handled like a WAL append failure", and fail closed. 2. Q8 window: if Resume() completes between the sync's SetBGError and FenceFailedGateSync, no fence is installed, because recovery's flush already kept the group and a fence installed then would never close. Argued, not tested. Rule: change the least code; an open fence that never closes would stop every later write. 3. Both gate syncs (the first one and the manual-flush/post-wait one) fence on failure. The post-wait one has the same exposure. Rule: the doc. 4. The hook sync point is deleted with the gate (the doc leaves this to me). No test needs it. 5. The C API compatibility allowlist gets the two removed opt-in accessors, because `make check-c-api-gen` against the base flags them. Rule: D-G18k = (i). 6. The Q1 test uses FaultInjectionTestEnv instead of FaultInjectionTestFS. Under FaultInjectionTestFS the neuter did not fail, because unsynced WAL data was not dropped on this path. Rule: the evidence standard (a test whose neuter passes proves nothing). 7. The Q1 test lives in its own file. A release `make` of db_test_util still fails at the base (it calls a TEST_ method under NDEBUG), and a standalone test is the only way to run Q1 in opt. Built with `DEBUG_LEVEL=0 make db_wal_partitions_open_test`. 8. Q7's race is widened with a 1 ms sleep at CheckpointImpl::CreateCustomCheckpoint:AfterGetLive1. Without it the neuter did not fail in 40 runs. This is the only sleep added, and it widens a window rather than waiting for an event. 9. The N=8 whitebox crash test pins --enable_blob_direct_write=0 --best_efforts_recovery=0. Without the pins, db_crashtest.py picked enable_blob_direct_write=1, which forces disable_wal=1 and makes the N>1 sanitizer fall back to one partition. The first wb8 attempt ran at N=1 for that reason and was discarded. 10. db_stress: at N>1 the LockWAL check skips GetCurrentWalFile() (no single current WAL). Rule: required for the Q4 crash tests; GC12 decided that API is NotSupported at N>1. 11. Q10 "sync moved back before insert": argued not to fail the two GC17 crash tests, so stronger neuters were run instead (see Q10). 12. GatePostWaitSyncFailureWakesParkedGate's expectation changed (W fails at the fence; parks 1-2 times). Rule: the Q8 ruling. 13. DBWalAppendFailureTest.UnrelatedErrorLeavesParkedWriteToComplete/0 (N=1) hangs now and then under heavy parallel load, in CloseHelper waiting on ReadyForShutdown. Under TSan it sometimes fails instead: the soft-error severity reads back as kNoError right after TEST_SetBGError, or the later parked-write check fails, consistent with the soft NoSpace error recovering on its own in the background. Paired runs show both are pre-existing: - debug: the base binary also hung (1 timeout in 92 runs before gtest-parallel aborted); - TSan, 2 x 100 runs each, base vs. this commit: base 10 and 6 failures, this commit 9 and 3, at the same two assertions; no TSan reports. This commit does not touch that test or its N=1 path, so it is excluded from the 100x sets below and reported here. ## Not done None of Q1-Q11 is cut. - Opt (DEBUG_LEVEL=0) runs of 15 of the 17 Verification suites: not run. Upstream RocksDB unit tests are debug-only: DBImpl's TEST_* methods are compiled only under !NDEBUG (db/db_impl/db_impl.h), and upstream db_test_util.cc and the test files call them. At facebook/rocksdb d6a7847 (the stack's upstream base), a release compile of db_test_util.o fails with 15 errors, and every Verification test object except wal_manager_test fails too (for example db_wal_test 131, error_handler_fs_test 430, transaction_test 191). The stack adds one more db_test_util error (TEST_WalPartitionForWrite, D127275775) and more in its test files. Making these build in release would mean exposing DBImpl's test hooks in production builds, which is outside this diff. Instead: Q1's standalone test, log_merge_test and wal_manager_test run in opt (Test plan). ## Test plan Clang-format 21.1.2. Tests used TEST_TMPDIR=~/pwal-3p/gc-18-claude-tmp, J=83 (half of 166 cores). Runs on a shared, loaded host are noted. All evidence below is from the final code unless marked. The last amend added only tools/c_api_gen/api_compatibility_allowlist.json and this message; no binary changes. - Debug, the 17 Verification suites plus write_prepared_transaction_test, db_wal_oracle_test, latency_injection_fs_test, db_wal_partitions_open_test and options_settable_test (22 binaries), gtest-parallel -w 50: 8842/8842 pass (exit 0). - c_test: PASS. - Opt: db_wal_partitions_open_test (Q1) in DEBUG_LEVEL=0: 20/20 PASS (both variants); log_merge_test 192/192 and wal_manager_test 12/12 PASS (DEBUG_LEVEL=0, built with TEST_LIBRARY=$(TESTHARNESS), the only Verification suites that compile in release); neuter fails as described. Other opt suites: not run (see Not done). - TSan (clang 21.1.0, USE_CLANG=1 COMPILE_WITH_TSAN=1) on every new or changed test: 823 test instances in db_write_test (DBWritePartitionTest, DBWalAppendFailureTest, DBWriteTestUnparameterized), db_options_test, ldb_cmd_test, optimistic/transaction/write_prepared partition tests, backup_engine_test *RacingLockWAL* and db_wal_partitions_open_test: 822 pass, 0 TSan reports. The 1 failure is the pre-existing N=1 UnrelatedErrorLeavesParkedWriteToComplete flake (Assumption 13). - 100x repeats of every new or changed SyncPoint/fault-injection test, debug: 5200/5200 (52 instances x 100); TSan: 5200/5200, 0 TSan reports. The 52 instances: the Q1 test (both), Q6 (all params), Q7 at N=8, FailedGateSyncWriteStaysInvisible, AsyncAboveSyncReturnsWhileSyncFsyncHeld, AsyncOnSyncingPartitionWaitsForItsFsync, PartialGateSyncCutLosesHigherAsyncWrite, CoalescedGateSyncsFsyncEachPartitionOnce, ManualWalFlushSyncWriteSurvivesCrash, GateSyncToleratesCoupledRotation, GateSyncFailureWakesParkedGate, GatePostWaitSyncFailureWakesParkedGate, SyncWriteAboveAsyncWriteSurvivesCrash, AckedAsyncWriteAboveUnsyncedHoleIsCut, SyncWriteSyncsAgainOnlyAfterWait, AsyncWriteDoesNotWaitForOtherPartitionsSync, the N1/N2 lock-order tests, CompletionWaitsForPriorPartitionAppend, PostWaitSyncErrorFailsSyncWrite (each at both params), WriteAdmittedByRecoveryAllocatesAboveFences, and [NonAtomic]CommitOfDelayedPrepared at N=8. Earlier, at a pre-final commit, the Q7 test also ran 200x at N=8 (1000 backups) with 0 bad copies. - GC15 oracle, no hook: 2000 cycles from seed 20261019, PASS (N=2 in 1007, N=8 in 993; power loss in 1034; a slow partition in 1016; 291 recoveries stopped at a cross-partition hole). The binary was built from library sources identical to the final commit (the last amend touched only db_write_test.cc and db_stress). - N=1 byte identity (db_bench fillseq, seed 20260928): none 6d1351117a289a2784449a68d5421b1aa385ab0b383273c2c5918befa9181b09, partition_by_column_family 9a69a3fc66777fadce05e8a999479a5f57364aca27cd6d22aa00e4631adfc796. Both equal the base hashes in the doc. - Crash tests, release db_stress from this commit, 180 s: - blackbox N=1 (partition_by_column_family): exit 0; - blackbox N=8 indexed: exit 0; - whitebox N=8 indexed: exit 0 (one check_mode=0 db_stress run at --wal_partitions=8 --disable_wal=0, killed at its interval with exitcode -15, then the normal "running too long" stop at the duration; --enable_blob_direct_write=0 --best_efforts_recovery=0 pinned, see Assumption 9). - make check-c-api-gen (API_COMPAT_REF = base): link-complete; compatible with the base (2 removals allowlisted); generated files up to date. N-6-1: rocksdb_options_{set,get}_wal_partitions present. - make check-sources: pass. Formatting: clang-format-diff over the commit (clang-format 21.1.2) reports no changes. `make check-format` was not used as-is: it diffs against origin/main and rewrote the license headers of 4 stack files that this commit does not touch. - Neuters: listed per question above. Each was rebuilt and its patched file confirmed in the build before the result was trusted.
JustinGaoF
force-pushed
the
pwal/gc18-claude
branch
from
October 28, 2026 01:31
0d352ff to
29df5aa
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] GC18 -- Indexed N>1 opens in production builds (G-01, G-63)
Reviewer question: With every gate item closed, does indexed N>1 now open
in production, does everything else stay rejected, and do the docs tell an
operator how to roll it out safely?
Short answer: yes. DB::Open accepts wal_partitions > 1 with an indexing
partition_wal_usage, with no sync point and no opt-in, in release and debug
builds. kNone + N>1 and every other M1.4 rejection still fail with their
exact Status. The wal_partitions doc comment and a new release note give
the rules, the rejected options, and the rollout order (readers first).
The GC13 opt-in is removed (D-G18k = (i)). The carry-over is done too:
Q8 fix (a sync write whose gate fsync fails stays invisible), plus Q6, Q7,
Q9, Q10 and Q11.
Out of scope / open gate rows: none. The stack owner confirmed every
Gate items row, or deferred it with a reason, before dispatch (table
below). No row is open, and nothing here fixes a gate item except Q8,
which the user ruled on 2026-10-26.
Decision: D-G18k = (i), remove the opt-in (the dispatcher's choice). The
option
experimental_allow_wal_partitions_for_testing, its OPTIONS-mapentry, Dump line and generated C accessors are deleted. db_bench,
db_stress and test::SetWalPartitions stop setting it. The debug sync point
DBImpl::ValidateOptions:AllowWalPartitionsis deleted with the gate, andall 20 uses in the 6 files are removed.
Q5 -- Gate items (copied as the stack owner filled them in)
Deferred by the user (2026-10-27), with the reason "not required for the
testing-stage flip; tracked for the land decision":
Checklist IDs per question:
hook-free); N-1-1 (upper bound).
pinned).
Answers
Q1 -- Indexed N>1 opens in a production build without hook or opt-in [G-01]
Property: DB::Open accepts WALIndexEnabled(partition_wal_usage) &&
wal_partitions > 1 when no other rejection applies. Default
wal_partitions stays 1. OpenForReadOnly, secondary and the other open
paths run the same ValidateOptions as at the base, so GC12's N>1
behaviour is unchanged (secondary and RepairDB still refuse partitioned
WALs; DBWritePartitionTest.ReadOnlyAndSecondaryApplyPartitionChecks and
ReadOnlyCompactedOpenAppliesPartitionChecks still pass, now hook-free).
How: db/db_impl/db_impl_open.cc deletes the gate block (the
DBImpl::ValidateOptions:AllowWalPartitionssync point and the opt-incheck). The kNone check that followed it stays; only its comment changes.
The M1.4 matrix comment is rewritten for the new legality.
Evidence: new file db/db_wal_partitions_open_test.cc,
DBWalPartitionsOpenTest.IndexedOpensWithoutHookAndRecoversPrefix/{0,1}.
It uses no sync point and nothing from the debug-only test harness, so it
builds in release. Setup: indexed N=4, 8 column families, 200 writes with
every fifth sync=true, at least 2 non-empty WALs asserted.
then reopen. Every write through the last sync=true one is present, and
the recovered set is a prefix of write order.
Passes 20x in release (DEBUG_LEVEL=0), 100x in debug and 100x under
TSan.
Neuter: restore the gate block. Open fails with
"NotSupported: wal_partitions > 1 is not supported yet (for any
partition_wal_usage)" in both variants (run in release).
Extra neuter: the original FaultInjectionTestFS version of this test
passed even with the gate fsync deleted, because unsynced data was not
dropped on this path. So the test uses FaultInjectionTestEnv, and with
the gate-time sync skipped the crash variant fails (a write above a hole
comes back).
Q2 -- The permanent rejections still hold [G-01, G-02, G-07, N-1-1]
Property: kNone + N>1 is rejected with NotSupported("wal_partitions > 1
requires partition_wal_usage other than kNone"), naming both options.
Every other N>1 rejection is unchanged. Exactly one check was removed:
the gate.
Evidence, all hook-free:
(indexed,4) open; (kNone,4) returns the exact NotSupported string.
rejects both options.
file with (kNone,4) fails Open naming both options; (indexed,4) opens.
the kNone message.
WalPartitionsUpperBound (65 is InvalidArgument; 64 opens),
WalPartitionsRequireParanoidChecks, and
WalPartitionsRejectionsNameTheirOptions (every M1.4 rejection, each
message naming its option).
ConcurrentUnsafeConfigsRejectedAtOpen, RejectsPipelinedWalPartitions,
RejectsSeqPerBatchTwoQueues.
Neuter: drop the kNone check. WalPartitionsUsageMatrix,
WalPartitionsValidation, IllegalWalPartitionsPairInOptionsFileFailsOpen
and UnindexedWalPartitionsAlwaysRejected fail ((kNone,4) opens).
Invariant 4: tests that asserted NotSupported for indexed N>1 without the
hook now assert that it opens:
dump_live_filesnow succeeds and lists every partition's current WAL.ldb opens from the OPTIONS file, which keeps wal_partitions and the
indexing usage.
IndexedWalPartitionsOpenFromOptionsFile: it opened with the opt-in and
asserted that a reopen from the OPTIONS file was refused. Now both open
and read back the data.
Each follows directly from the lifted gate. No other expectation changed.
Q3 -- The option doc and release note describe the shipped behaviour [G-01, S-17]
include/rocksdb/options.h, wal_partitions (final text):
// EXPERIMENTAL
//
// The number of WAL files ("partitions") that writes are spread across.
//
// A single WAL file admits only one append in flight at a time, because
// durability granularity is per file descriptor. On storage where append
// latency is high relative to bandwidth, that single outstanding I/O bounds
// write throughput no matter how fast the device is. Spreading writes over N
// WAL files allows N concurrent appends. Recovery merges the partitions back
// into a single stream ordered by the WAL index that partition_wal_usage
// records, so the logical log is unchanged.
//
// Values greater than 1 require a partition_wal_usage other than kNone,
// which records the order recovery needs to merge the partitions;
// partition_wal_usage = kNone with wal_partitions > 1 is rejected at Open()
// with Status::NotSupported. Values above 64 are rejected with
// Status::InvalidArgument. With more than one partition, Open() also rejects
// two_write_queues, enable_pipelined_write, unordered_write,
// track_and_verify_wals, recycle_log_file_num > 0,
// allow_concurrent_memtable_write = false, paranoid_checks = false,
// track_and_verify_wals_in_manifest = false, and, per column family,
// inplace_update_support, enable_blob_direct_write, max_successive_merges > 0
// and any memtable other than the skip list, as well as
// OptimisticTransactionDB with serial validation; each message names the
// conflicting option. WriteWithCallback() with a callback,
// WriteBatchWithIndex ingestion and GetUpdatesSince() return
// Status::NotSupported. With the default of 1 the WAL is byte-for-byte
// identical to a build without this option.
//
// manual_wal_flush is supported but not recommended with more than one
// partition: FlushWAL() flushes every partition's buffer while holding every
// partition's WAL write lock, which re-imposes the coordinated flushing that
// partitions exist to avoid.
//
// Enabling more than one partition is a rollout step: every binary that may
// read these WAL files (the DB itself on reopen or rollback, ldb, backup and
// checkpoint restore, RepairDB, secondary instances) must first be upgraded
// to one that understands partitioned, indexed WALs, before any DB is
// opened with wal_partitions > 1. Secondary instances and RepairDB refuse
// partitioned WAL files with Status::NotSupported.
//
// Not dynamically changeable via SetOptions().
//
// Default: 1
uint32_t wal_partitions = 1;
unreleased_history/new_features/wal_partitions.md (new):
DBOptions::wal_partitionsvalues above 1 are now accepted(EXPERIMENTAL). Writes are spread across that many WAL files so that
appends to them proceed concurrently; recovery merges them back into one
ordered log. It requires
partition_wal_usageother thankNone(thecombination with
kNoneis rejected), is limited to 64, cannot bechanged with
SetOptions(), and is rejected together with the optionslisted in its documentation (for example
two_write_queues,enable_pipelined_write,unordered_write, andtrack_and_verify_wals_in_manifest = false). Enabling it is a rolloutstep: first deploy a binary that understands partitioned, indexed WALs
everywhere these WAL files may be read (the DB itself, ldb, backup and
checkpoint restore, RepairDB, secondary instances), and only then open a
DB with
wal_partitions > 1.manual_wal_flushis supported but notrecommended with more than one partition.
partition_wal_usage's doc (D118367634) says nothing that contradicts
this, so it is unchanged. Each option listed is enforced by a test named
under Q2. Argued, not tested beyond that (docs).
Q4 -- Tools and tests are off the hook and the opt-in [D-G18k = (i)]
Removed:
(type map, ctor, Dump), options/options_helper.cc,
options/options_settable_test.cc.
make regen-c-api(db/c.cc,include/rocksdb/c.h, c_api_gen/*.inc). Both removals are recorded in
tools/c_api_gen/api_compatibility_allowlist.json with the reason
(never released).
db_bench (assignment and flag help), db_stress (two assignments and the
flag help), db_wal_oracle_test, latency_injection_fs_test.
OpenWithPartitions/ReopenWithPartitions, the write_prepared fixture and
the individual tests), ldb_cmd_test.cc, optimistic_transaction_test.cc,
transaction_test.cc and write_prepared_transaction_test.cc.
Each deleted hook callback only made the deleted gate pass. Removing it
is behaviour-neutral for indexed N>1, because the gate no longer exists.
Where a callback was the test's only reason to call EnableProcessing(),
the call stays if later sync points in the test need it
(OpenWithPartitions, ReopenWithPartitions, the WritePreparedPartitionedWal
fixture, transaction_test's
SnapshotCommitPublishesAboveHeldLowerWrite). Otherwise the call and its
paired Disable/ClearAllCallBacks are removed.
db_crashtest.py is unchanged: it never passed the opt-in (db_stress set
it internally). Its N in {1,2,8,16} sweep now runs in a plain opt build.
One db_stress fix the flip exposes: the LockWAL verification called
GetCurrentWalFile(), which is NotSupported at N>1 (there is no single
current WAL). The bb8 run failed on it with "GetCurrentWalFile() failed:
Not implemented". At N>1 that one check is skipped; the seqno check still
runs (db_stress_tool/db_stress_test_base.cc).
Evidence: release db_stress from this commit, 180 s each:
--wal_partitions=8;
git grepfinds noexperimental_allow_wal_partitionsand noAllowWalPartitions.Q5 -- M3 reached [G-63]
See the gate table and the per-question checklist lines above.
Q6 -- WritePrepared 2PC with the commit marker on another partition recovers atomically [G-55]
Ported from GC14a's Muse candidate (pwal/ab/gc14a-muse-PR5, 07dbcab);
credit to it: WritePreparedTransactionTest.
TwoPhaseCommitSpanningPartitionsRecoversAtomically plus its friend line in
write_prepared_txn_db.h. Only those two pieces are ported (no
db_filesnapshot.cc change).
The test: at N in {2,8} it finds an XID whose CF-less commit marker
routes to a different partition than the prepare (asserted through
DBImpl::WriteToWAL:AppendOutcome). Then, in each of the 4 recovery modes,
it crashes before or after the commit:
visible;
Evidence: passes, 100x debug, 100x TSan: 100/100 debug and 100/100 TSan, no TSan report (every instance, including the 9 WritePreparedTransaction params).
Neuter: recovery drops a commit marker read from a partition other than
the prepare's. The crash-after cells fail at mode=1 (
xaNotFound: thetransaction comes back uncommitted).
Q7 -- Flush-less backup racing LockWAL/UnlockWAL [G-30 residual]
New test BackupEngineTest.BackupWithoutFlushRacingLockWAL
(utilities/backup/backup_engine_test.cc), modelled on
CheckpointRacingLockWAL; it runs in the WalPartitions8 instantiation
among others. Writers run on every partition while a locker thread loops
LockWAL/UnlockWAL, and 5 CreateNewBackup(flush_before_backup=false)
calls each finish within RunWithin(30 s). Each backup is restored by ID
and checked in every recovery mode: it opens and holds a per-writer
prefix that includes every write acknowledged before the backup.
A 1 ms sleep at CheckpointImpl::CreateCustomCheckpoint:AfterGetLive1
widens the race window. Without it the neuter did not fail in 40 runs.
Evidence: 200 repeats of the N=8 case = 1000 backups, 0 unopenable or
non-prefix copies. Re-run at the final commit: WalPartitions8 case 100/100 debug (500 backups) and 100/100 TSan (500 backups), 0 unopenable or non-prefix copies.
Neuter: restore the pre-GC14a skip-then-read order in
GetLiveFilesStorageInfoImpl (no pinned LockWAL count). 3 of 40 runs
(200 backups) fail with an unopenable or non-prefix restore.
Q8 -- A sync write whose gate fsync fails stays invisible [GC17 carry-over; fix]
Before: at N>1 a sync write is inserted and published before its gate
fsync. When that fsync failed, the write returned IOError, but its
records could be published, and after Resume() flushed and kept.
Now a failed gate sync is handled like a failed append:
when its sync() fails, before any coalesced waiter may start its own
sync. FenceFailedGateSync installs a gate fence at the group's first
sequence, using the background error that the sync's WALIOStatusCheck
raised, with released_by_recovery = true.
never publishes into an open fence. A failed append or insert leaves
its range unapplied anyway; a failed gate sync fences a range that has
already applied.
DropEntriesAtOrAbove), and every gate in the fence returns the error.
such a fence.
lambdas (WriteImpl: current_sequence; WriteImplWALOnly:
last_sequence + 1).
manual-flush/post-wait one.
hits the fence and returns the background error. One whose own sync
fails fences itself.
N=1 is unchanged: all of this is under NumWalPartitions() > 1, and N=1
WAL bytes match the base (below).
Evidence: DBWritePartitionTest.FailedGateSyncWriteStaysInvisible
(N in {2,8}).
gate sync fails with a retryable IOError. Get(B) is NotFound before
Resume(), after Resume() plus Flush, and after a reopen in each of the
4 recovery modes. Every acknowledged write below B is present each time.
is held, and the sync fails. Same checks: C and D are absent and A2's
lower writes are present.
100x debug, 100x TSan: 100/100 debug and 100/100 TSan, no TSan report (both N).
Neuter: skip FenceFailedGateSync. key_b becomes visible ("value_b")
after Resume() plus Flush.
Changed by design (this ruling): GatePostWaitSyncFailureWakesParkedGate.
Parked writer W now fails at B's fence, so it may park once or twice
(error wake, then fence wake; TSan scheduling shows the second), and it
returns. The test asserts w_parks in [1,2], no waiters, w_returned.
Q9 -- An async append's wait for its own partition's fsync is pinned [GC17 carry-over]
Ported from GC17's Muse candidate (pwal/ab/gc17-muse-PR7, 110e488);
credit to it: the sync point
DBImpl::SyncWalPartitionFiles:BeforeSyncPartition(fires per partitionunder that partition's mutex, db/db_impl/db_impl.cc) and
AsyncAboveSyncReturnsWhileSyncFsyncHeld. New q-variant:
AsyncOnSyncingPartitionWaitsForItsFsync.
partition r completes within RunWithin.
WriteThread::JoinBatchGroup:Start, then sees it still pending after
100 ms. It completes once q's fsync is released.
100x debug, 100x TSan: 100/100 debug and 100/100 TSan, no TSan report (both tests, both params).
Neuter: hold every partition's WAL mutex across the whole multi-partition
fsync. The r-write does not finish and RunWithin aborts after 30 s.
Q10 -- GC17's test gaps [GC17 carry-over]
credit) replaces the vacuous LeadershipSyncExcludesCoupledRotation. A
coupled rotation inside the gate-sync window leaves the partition deques
consistent, and a second sync write succeeds.
candidate; credit). After a partial gate-sync failure and a crash, the
default mode fails closed and point-in-time recovery recovers a prefix.
on several partitions queue at RunCoalescedGateSync:BeforeWait (new
sync point). Each is acknowledged only after every partition has synced
through its sequence. Exactly 2 fsyncs per partition happen: the
leader's round and one coalesced round for all waiters. A crash then
keeps every acknowledged write.
Neuter: the coalescer skips the last partition. q3 is NOT_FOUND after
the crash.
asserts, at ErrorHandler::ClearBGError:BeforeClearStopped through
TEST_WalGateFences() (ported accessor; credit GC17's Muse candidate),
that the fences are non-empty and closed. The writer waits by retry,
not a fixed sleep.
Neuters: drop GC08's fence creation, and fences_at_hold is empty; swap
ClearBGError's two steps, and a fence is still open at the hold.
writes at N>1 survive a crash that drops unsynced data.
Neuter: skip the gate sync, and an acknowledged sync write is lost.
AckedAsyncWriteAboveUnsyncedHoleIsCut, with neuters actually run:
(and SyncWriteMakesPrior..., ManualWalFlushSyncWriteSurvivesCrash and
the Q1 crash test) fail;
fail (C present).
The doc's "sync moved back before insert" neuter does not fail them:
a leader-time sync also covers the lower write. Argued, so the two
neuters above stand in for it.
100/100, no TSan report.
Q11 -- Sync-point names match the gate-time sync [GC17 carry-over]
Renames (no behaviour change):
DBImpl::SyncWalsFromCompletionGate:TakesSyncMarkMutex
DBImpl::SyncEveryWalPartition:TakesPartitionSyncMutex
DBImpl::SyncWalsFromCompletionGate:AfterGateSync
The N=1 leader-time site keeps
DBImpl::WriteGroupToWAL:AfterLeadershipSync,where it really fires (db_wal_test uses it).
names.
git grepfinds no old name at a gate-time site.GateSyncFailureWakesParkedGate (gate_sync wording).
Each renamed point's tests pass, and they fail under their neuters
(GateSyncFailureWakesParkedGate, the N1/N2 lock-order tests, the Q9/Q10
tests above). Argued behaviour-neutral.
Fold-back split
Adding diffs come from
git blameat a855854 plus each commit'sDifferential Revision:line. a855854 itself has no such line; the docnames it D127837663. None of its lines are modified here.
Flip (Q1-Q5): stays the standalone diff on top, never folded.
D117251769 (2);
D117251769.
options/options_settable_test.cc: D117251769.
output for the D117251769 field).
db_stress_tool/db_stress_test_base.cc :4683 and :7187: D117251769.
(The doc expected D118371518; blame says D117251769.)
upstream code; part of the flip.
D127275775 (DumpWalAtWalPartitions).
D123701876 (hook removal per test).
(fixture hook): D123079329.
(opt-in line): D126533193.
WalPartitionsTestingOptIn -> IndexedWalPartitionsOpenFromOptionsFile
rewrite: the diffs that added each test (D117251769 for the
unparameterized tests, D123079329 and later for the fixture).
src.mk, CMakeLists.txt and BUCK lines: new code, flip.
Q8 -> D123701876, with a flag.
the fence set and released_by_recovery first exist. So all Q8 code
goes to D123701876 (the lowest diff where it compiles), not to
D123551605.
ReopenWithPartitions (D123928339), so the test can only live at
D123928339.
D123701876.
Q6 -> D127275775: the write_prepared_transaction_test.cc test and the
write_prepared_txn_db.h friend line (blame: upstream neighbours; new
code).
Q7 -> D127275775: backup_engine_test.cc, new test (neighbour from
D127275775).
Q9 -> D123971668: the sync point in SyncWalPartitionFiles. The two tests
reopen with partitions: D123928339 or above. The tests use
ReopenWithPartitions, so they go to D123971668 together with the sync
point.
Q10:
LeadershipSyncExcludesCoupledRotation; blame D126533193). The doc's map
says D123928339; FLAG: it uses the D123971668 sync point, so it goes to
D123971668 or its blamed D126533193.
CoalescedGateSyncsFsyncEachPartitionOnce (with the
RunCoalescedGateSync:BeforeWait sync point, code from D123551605) and
ManualWalFlushSyncWriteSurvivesCrash: D123971668 (they use the
reopen helpers and the per-partition sync point).
Q11:
SyncEveryWalPartition: D123551605.
each test (D123551605 / D123701876 / D123928339).
Assumptions
AsyncWriteDoesNotWaitForOtherPartitionsSync). A sync write may already
be visible when its fsync fails, so "never visible" holds from the
failure on. If a reader saw the write before the failure, the write is
dropped at Resume() together with any acknowledged async writes above
it, since they sit above an unsynced hole, as for a failed append.
Rule: the doc's "handled like a WAL append failure", and fail closed.
FenceFailedGateSync, no fence is installed, because recovery's flush
already kept the group and a fence installed then would never close.
Argued, not tested. Rule: change the least code; an open fence that
never closes would stop every later write.
fence on failure. The post-wait one has the same exposure. Rule: the
doc.
me). No test needs it.
accessors, because
make check-c-api-genagainst the base flags them.Rule: D-G18k = (i).
FaultInjectionTestFS. Under FaultInjectionTestFS the neuter did not
fail, because unsynced WAL data was not dropped on this path. Rule: the
evidence standard (a test whose neuter passes proves nothing).
makeof db_test_utilstill fails at the base (it calls a TEST_ method under NDEBUG), and a
standalone test is the only way to run Q1 in opt. Built with
DEBUG_LEVEL=0 make db_wal_partitions_open_test.CheckpointImpl::CreateCustomCheckpoint:AfterGetLive1. Without it the
neuter did not fail in 40 runs. This is the only sleep added, and it
widens a window rather than waiting for an event.
--best_efforts_recovery=0. Without the pins, db_crashtest.py picked
enable_blob_direct_write=1, which forces disable_wal=1 and makes the
N>1 sanitizer fall back to one partition. The first wb8 attempt ran at
N=1 for that reason and was discarded.
single current WAL). Rule: required for the Q4 crash tests; GC12
decided that API is NotSupported at N>1.
crash tests, so stronger neuters were run instead (see Q10).
at the fence; parks 1-2 times). Rule: the Q8 ruling.
(N=1) hangs now and then under heavy parallel load, in CloseHelper
waiting on ReadyForShutdown. Under TSan it sometimes fails instead: the
soft-error severity reads back as kNoError right after TEST_SetBGError,
or the later parked-write check fails, consistent with the soft NoSpace
error recovering on its own in the background. Paired runs show both
are pre-existing:
gtest-parallel aborted);
failures, this commit 9 and 3, at the same two assertions; no TSan
reports.
This commit does not touch that test or its N=1 path, so it is excluded
from the 100x sets below and reported here.
Not done
None of Q1-Q11 is cut.
Upstream RocksDB unit tests are debug-only: DBImpl's TEST_* methods are
compiled only under !NDEBUG (db/db_impl/db_impl.h), and upstream
db_test_util.cc and the test files call them. At facebook/rocksdb
d6a7847 (the stack's upstream base), a release compile of
db_test_util.o fails with 15 errors, and every Verification test object
except wal_manager_test fails too (for example db_wal_test 131,
error_handler_fs_test 430, transaction_test 191). The stack adds one
more db_test_util error (TEST_WalPartitionForWrite, D127275775) and more
in its test files. Making these build in release would mean exposing
DBImpl's test hooks in production builds, which is outside this diff.
Instead: Q1's standalone test, log_merge_test and wal_manager_test run
in opt (Test plan).
Test plan
Clang-format 21.1.2. Tests used TEST_TMPDIR=~/pwal-3p/gc-18-claude-tmp,
J=83 (half of 166 cores). Runs on a shared, loaded host are noted.
All evidence below is from the final code unless marked. The last amend
added only tools/c_api_gen/api_compatibility_allowlist.json and this
message; no binary changes.
db_wal_oracle_test, latency_injection_fs_test,
db_wal_partitions_open_test and options_settable_test (22 binaries),
gtest-parallel -w 50: 8842/8842 pass (exit 0).
(both variants); log_merge_test 192/192 and wal_manager_test 12/12 PASS
(DEBUG_LEVEL=0, built with TEST_LIBRARY=$(TESTHARNESS), the only
Verification suites that compile in release); neuter fails as described. Other opt suites: not run (see
Not done).
changed test: 823 test instances in db_write_test (DBWritePartitionTest, DBWalAppendFailureTest, DBWriteTestUnparameterized), db_options_test, ldb_cmd_test, optimistic/transaction/write_prepared partition tests, backup_engine_test RacingLockWAL and db_wal_partitions_open_test: 822 pass, 0 TSan reports. The 1 failure is the pre-existing N=1 UnrelatedErrorLeavesParkedWriteToComplete flake (Assumption 13).
debug: 5200/5200 (52 instances x 100); TSan: 5200/5200, 0 TSan reports. The 52 instances: the Q1 test (both), Q6 (all params), Q7 at N=8, FailedGateSyncWriteStaysInvisible, AsyncAboveSyncReturnsWhileSyncFsyncHeld, AsyncOnSyncingPartitionWaitsForItsFsync, PartialGateSyncCutLosesHigherAsyncWrite, CoalescedGateSyncsFsyncEachPartitionOnce, ManualWalFlushSyncWriteSurvivesCrash, GateSyncToleratesCoupledRotation, GateSyncFailureWakesParkedGate, GatePostWaitSyncFailureWakesParkedGate, SyncWriteAboveAsyncWriteSurvivesCrash, AckedAsyncWriteAboveUnsyncedHoleIsCut, SyncWriteSyncsAgainOnlyAfterWait, AsyncWriteDoesNotWaitForOtherPartitionsSync, the N1/N2 lock-order tests, CompletionWaitsForPriorPartitionAppend, PostWaitSyncErrorFailsSyncWrite (each at both params), WriteAdmittedByRecoveryAllocatesAboveFences, and [NonAtomic]CommitOfDelayedPrepared at N=8. Earlier, at a pre-final commit, the Q7 test also ran 200x at N=8 (1000 backups) with 0 bad copies.
with the base (2 removals allowlisted); generated files up to date.
N-6-1: rocksdb_options_{set,get}_wal_partitions present.
make check-formatwas not used as-is: it diffs against origin/main and rewrote the license headers of 4 stack files that this commit does not touch.file confirmed in the build before the result was trusted.