Skip to content

Support disableWAL with recycle_log_file_num (#15581) - #15581

Closed
jaykorean wants to merge 1 commit into
meta:mainfrom
jaykorean:export-D129451715
Closed

jaykorean wants to merge 1 commit into
meta:mainfrom
jaykorean:export-D129451715

Conversation

@jaykorean

@jaykorean jaykorean commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Why the change is required:
WriteOptions::disableWAL returns Status::InvalidArgument when DBOptions::recycle_log_file_num > 0 (T185140603), and the crash test forces recycle_log_file_num=0 whenever disable_wal=1. The root cause also loses data without disableWAL: external file ingestion consumes a sequence number without a WAL record, which is the recovery data loss reproduced by the disabled DBWALTest.RecycleMultipleWalsCrash (github PR 12918) and the reason WAL recycling is off in the crash test.

Previous behavior:
After a crash, a recycled WAL usually ends with records of its previous incarnation. In kPointInTimeRecovery the log reader reports such a record through OldLogRecord(). Since it cannot be told apart from a corrupted record, recovery stops replaying there and only continues into the next WAL if that WAL's first WriteBatch has exactly the sequence number recovery expects next (github PR 12403, D54544824). Any sequence numbers consumed between the last WriteBatch of one WAL and the first WriteBatch of the next without a WAL record (an unlogged write, an ingested file) fail that check, so recovery silently drops every later WAL, including acknowledged sync writes, or fails DB::Open with "SST file contains data beyond the point of corruption" when a column family was already flushed past it. PR 12403 therefore rejected disableWAL with recycling, PR 12639 exempted WritePrepared's internal split writes, and ingestion was never covered.

New behavior:

  • disableWAL writes are accepted with recycle_log_file_num > 0 for plain DBs and WriteCommitted and optimistic transaction DBs. WritePrepared and WriteUnprepared (seq_per_batch) still return InvalidArgument, exactly as before (with a message that now names them).
  • Point-in-time recovery from recycled WALs no longer drops WAL data after sequence numbers consumed outside the WAL at a WAL boundary, whether by disableWAL writes, ingestion, or other features. A batch ending a WAL with a user WriteBatch::MarkWalTerminationPoint() keeps the old stop-replay behavior (see below).
  • Real corruption in a recycled WAL still stops recovery at the same point as before.

Implementation:

  • DBImpl tracks next_seq_after_last_wal_record_: the sequence number recovery reaches after replaying the last WriteBatch successfully added to a WAL, i.e. its sequence plus the sequence numbers it consumes. WriteToWAL() and WriteGroupToWAL() take that count (seq_inc in WriteImpl() and ConcurrentWriteGroupToWAL(), total_count in PipelinedWriteImpl(), 0 for the DB::Open dummy entry). A failed WAL write sets it to 0 (unknown).
  • Before the first WriteBatch of each WAL (log::Writer::GetLastSeqnoRecorded() == 0), MaybeAddWalSeqnoGapFiller() writes an empty WriteBatch whose sequence number is the expected one, if recycling is on, seq_per_batch_ is false, the expected number is known, and the first WriteBatch skips ahead of it. Recovery's continuity check then compares against the filler instead of the first real WriteBatch. This is the same trick DB::Open already uses (an empty batch at the recovered sequence number) to keep point-in-time recovery working across WritePrepared gaps.
  • The fix is entirely on the write side and keyed on what was actually written to the WAL, so it does not depend on auditing every feature that consumes sequence numbers, which was the concern in PR 12918. The recovery code is unchanged.
  • The InvalidArgument check now applies only with seq_per_batch_. The crash-test workaround is removed.

Safety, compatibility, and limitations:

  • Corruption detection: if corruption truncates WAL N (a record whose header log number is damaged looks like an old record; other damage fails the checksum), recovery ends WAL N below the filler's sequence number and stops, as it did when the next WAL started with a real WriteBatch. Detection power equals the existing continuity check; losing records that consume no sequence numbers (WriteCommitted prepares, empty batches) was never detected and still is not.
  • Format: no new record type. The filler is a regular record holding an empty WriteBatch, which every RocksDB version reads, and older versions apply the same continuity check, so they also recover these WALs correctly after a downgrade. Fillers are written only with recycling on and a sequence gap at the start of a WAL, so WALs of existing workloads without such gaps are unchanged byte for byte.
  • Safety invariant: a filler must never be below the sequence number recovery reaches after the previous WAL, or CheckSeqnoNotSetBackDuringRecovery() would fail DB::Open. Recovery reproduces sequence plus seq_inc for each WriteBatch without seq_per_batch (keys outside prepare sections, the prepared batch at a commit marker, reserved WBWI counts). Cases where recovery advances less (a WalFilter dropping entries, a commit marker whose prepare is gone, a user WAL termination point that cuts keys from the logged batch) only make the filler larger than needed, which at worst falls back to the old stop-replay behavior. Fillers are skipped when the expected number is unknown, such as after a failed WAL write.
  • Observable side effects: a WalFilter or GetUpdatesSince() can see an extra empty WriteBatch, as they already can for the DB::Open dummy entry. GetUpdatesSince() already reported such gaps as "Gap in sequence numbers".
  • Performance: per WAL write group, one load and compare of the writer's last recorded sequence number (true once per WAL) plus one store; disableWAL writes are unchanged. See the benchmark below.
  • Not covered: WritePrepared and WriteUnprepared keep the restriction. Their own internal unlogged writes (e.g. the commit publish write with two_write_queues) can already leave gaps at WAL boundaries under recycling; that pre-existing issue is unchanged here and needs follow-up. The crash test still defaults recycle_log_file_num to 0; enabling it at random is left to a follow-up after more stress runs.

Requested by: Jay Huh (jewoongh)

Reviewed By: xingbowang

Differential Revision: D129451715

@meta-cla meta-cla Bot added the CLA Signed label Nov 3, 2026
@meta-codesync

meta-codesync Bot commented Nov 3, 2026

Copy link
Copy Markdown

@jaykorean has exported this pull request. If you are a Meta employee, you can view the originating Diff in D129451715.

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

✅ clang-tidy: No findings on changed lines

Completed in 600.1s.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Claude Code Review - OBSOLETE

Superseded by a newer AI review. Expand to see the original review.

✅ Claude Code Review

Auto-triggered after CI passed — reviewing commit 35db9c1


Summary

Well-designed and carefully reasoned fix for a real data-loss bug in WAL recovery with recycled logs. The gap-filler approach is elegant -- it fixes the problem on the write side without touching recovery code, and it's backwards-compatible since older RocksDB versions process the filler identically. The change correctly limits scope by excluding seq_per_batch (WritePrepared/WriteUnprepared) and is well-tested.

High-severity findings (0):

No high-severity findings.

Full review (click to expand)

Findings

🔴 HIGH

None.

🟡 MEDIUM

M1. Gap filler bytes not counted in wals_total_size_ or WAL_FILE_BYTES stats -- db_impl_write.cc:2387
  • Issue: MaybeAddWalSeqnoGapFiller() calls log_writer->AddRecord() directly, bypassing the wals_total_size_.FetchAddRelaxed() and WAL_FILE_BYTES accounting in WriteToWAL() (which only accounts for the main log_entry). The filler record's bytes are untracked.
  • Root cause: The filler is written as a side effect inside WriteToWAL, before the main log_entry size accounting at line 2373. The *log_size output and the wals_total_size_ update reflect only the caller's batch, not the filler.
  • Impact: wals_total_size_ undercounts total WAL bytes, which could delay WAL-size-triggered flushes (when max_total_wal_size is set). The gap filler is small (a WriteBatch header ~12 bytes + record header ~11 bytes), so real-world impact is negligible. Still, the accounting inconsistency is worth noting.
  • Suggested fix: Add the filler's serialized size to *log_size or call wals_total_size_.FetchAddRelaxed() for the filler record. Alternatively, document why this is intentionally ignored.
M2. next_seq_after_last_wal_record_ not reset on MaybeAddUserDefinedTimestampSizeRecord failure -- db_impl_write.cc:2360
  • Issue: If MaybeAddUserDefinedTimestampSizeRecord fails (line 2360), WriteToWAL returns early before the next_seq_after_last_wal_record_ update. The field retains its value from the previous successful write. While the WAL write fails and triggers error handling, the stale value could theoretically cause an incorrect filler on a subsequent write if the error is somehow recovered.
  • Root cause: The early return at line 2361 predates this change and skips all post-AddRecord logic.
  • Impact: Low in practice -- a UDT size record failure cascades to a WAL error that typically puts the DB into an error state. Pre-existing pattern.
  • Suggested fix: Consider setting next_seq_after_last_wal_record_ = 0 on the early return path, consistent with the io_s.ok() ? ... : 0 pattern used for the main record.
M3. DB::Open dummy batch sets next_seq_after_last_wal_record_ to recovered_seq (not recovered_seq + 1) -- db_impl_open.cc:2840
  • Issue: After DB::Open writes the dummy empty batch at sequence recovered_seq with seq_inc=0, next_seq_after_last_wal_record_ becomes recovered_seq + 0 = recovered_seq. This is the sequence of the dummy batch itself, not the next expected sequence. The first real write after Open will be at sequence >= recovered_seq + 1.
  • Root cause: The dummy batch has Count=0, so seq_inc=0 is correct for how recovery treats it (0 sequence numbers consumed). But from the filler's perspective, recovery would advance to recovered_seq (not past it) after replaying the dummy batch.
  • Analysis: This actually works correctly because: (1) The first real write after Open goes into the SAME WAL as the dummy batch (the WAL opened by DB::Open). (2) Since the dummy batch's AddRecord sets GetLastSeqnoRecorded() to recovered_seq (non-zero), the GetLastSeqnoRecorded() == 0 check returns false for the first real write in this WAL. (3) The filler is only triggered for the first write in a NEW WAL. By that time, the previous WAL's writes have set next_seq_after_last_wal_record_ correctly. So no bug, but the reasoning is subtle enough to warrant a comment.
  • Suggested fix: Add a comment at the seq_inc=0 call site explaining why this is correct.

🟢 LOW / NIT

L1. Consider asserting !seq_per_batch_ in MaybeAddWalSeqnoGapFiller -- db_impl_write.cc:2393
  • Issue: The function returns early when seq_per_batch_ is true, but does so silently. An assertion after the early return (or a comment) would catch callers who accidentally use this in a seq_per_batch context after future refactoring removes the guard in WriteImpl.
  • Impact: Defensive coding improvement.
L2. Test RecycleWalsWithUnloggedWrites uses EXPECT_EQ for gap filler count -- db_wal_test.cc
  • Issue: EXPECT_EQ(gap_fillers.load(), 2) could be ASSERT_EQ since if the count is wrong, the subsequent recovery verification is testing a different scenario than intended.
  • Impact: Test quality only.
L3. CorruptRecycledWalRecord hardcodes record header layout offset 7 -- db_wal_test.cc:145
  • Issue: The helper writes at record_offset + 7 to overwrite the log number, assuming the log record header layout (4-byte CRC + 2-byte length + 1-byte type = 7 bytes before log number). This is correct for the current recyclable format but fragile.
  • Impact: Test-only. Low risk since log format is stable, and a header change would break many things.
L4. VerifyWalFilesToRecycle uses EXPECT_* where ASSERT_* may be more appropriate -- db_wal_test.cc:97
  • Issue: If the WAL count assertion fails, subsequent test steps proceed with incorrect assumptions.
  • Impact: Test quality only.

Cross-Component Analysis

Context Does code execute? Assumptions hold? Action needed?
WritePreparedTxnDB YES - guarded by seq_per_batch_ N/A - correctly excluded None
WriteUnpreparedTxnDB YES - same as above N/A - correctly excluded None
ReadOnly DB NO - no writes N/A None
User-defined timestamps YES - UDT size record before filler GetLastSeqnoRecorded() not affected by UDT record Safe
External file ingestion YES - creates the gap the filler bridges Correctly addressed Safe
unordered_write YES - WriteImplWALOnly -> ConcurrentWriteGroupToWAL seq_inc correct via kDoAssignOrder Safe
PipelinedWrite YES - WriteGroupToWAL -> WriteToWAL seq_inc = total_count, correct Safe
two_write_queues (WriteCommitted) YES - under wal_write_mutex_ Synchronization correct Safe
manual_wal_flush_ YES - filler under same lock Correct Safe
Other WAL recovery modes YES - filler written regardless Benign (empty WriteBatch) Safe
Older RocksDB versions (downgrade) YES - read as normal empty batch Continuity check works same way Safe

DB Mutex Analysis

The changed code does not execute while DBImpl::mutex_ is held, except for the DB::Open path (db_impl_open.cc:2839-2841) where the mutex is held per impl->mutex_.AssertHeld(). The DB::Open path with seq_inc=0 does minimal additional work (the gap filler early-returns because next_seq_after_last_wal_record_ is 0). No change to mutex-held critical section cost.

The main write path (WriteToWAL) runs outside the DB mutex. The gap filler adds one log_writer->AddRecord() call amortized once per WAL file (not per write group), which is negligible.

Positive Observations

  • Elegant design: The fix is entirely on the write side, requiring no changes to recovery code. This means older RocksDB versions can correctly recover WALs produced by the new code.
  • Correct scoping: Excluding seq_per_batch_ avoids complex interactions and is clearly documented with a follow-up path.
  • Good reuse of existing patterns: The gap filler reuses the "empty WriteBatch" trick already used by DB::Open, making it a natural extension.
  • Thorough test coverage: Tests cover all four write paths, verify gap filler invocation count, and test that corruption detection still works. The RecycleWalsWithUnloggedWritesDetectCorruption test is particularly well-designed.
  • Good test refactoring: Common patterns extracted into reusable helpers (DisableWalTruncationOnClose, VerifyWalFilesToRecycle, PopulateWalsToRecycle).
  • Correct synchronization: next_seq_after_last_wal_record_ protected by the same synchronization as WriteToWAL.
  • Re-enabling DISABLED_RecycleMultipleWalsCrash: Previously disabled test now passing.

ℹ️ About this response

Generated by Claude Code.
Review methodology: claude_md/ci_review_prompt.md

Limitations:

  • Claude may miss context from files not in the diff
  • Large PRs may be truncated
  • Always apply human judgment to AI suggestions

Commands:

  • /claude-review [context] — Request a code review
  • /claude-query <question> — Ask about the PR or codebase

@meta-codesync meta-codesync Bot changed the title Support disableWAL with recycle_log_file_num Support disableWAL with recycle_log_file_num (#15581) Nov 9, 2026
jaykorean added a commit to jaykorean/rocksdb that referenced this pull request Nov 9, 2026
Summary:

Why the change is required:
`WriteOptions::disableWAL` returns `Status::InvalidArgument` when `DBOptions::recycle_log_file_num > 0` (T185140603), and the crash test forces `recycle_log_file_num=0` whenever `disable_wal=1`. The root cause also loses data without disableWAL: external file ingestion consumes a sequence number without a WAL record, which is the recovery data loss reproduced by the disabled `DBWALTest.RecycleMultipleWalsCrash` (github PR 12918) and the reason WAL recycling is off in the crash test.

Previous behavior:
After a crash, a recycled WAL usually ends with records of its previous incarnation. In `kPointInTimeRecovery` the log reader reports such a record through `OldLogRecord()`. Since it cannot be told apart from a corrupted record, recovery stops replaying there and only continues into the next WAL if that WAL's first WriteBatch has exactly the sequence number recovery expects next (github PR 12403, D54544824). Any sequence numbers consumed between the last WriteBatch of one WAL and the first WriteBatch of the next without a WAL record (an unlogged write, an ingested file) fail that check, so recovery silently drops every later WAL, including acknowledged `sync` writes, or fails `DB::Open` with "SST file contains data beyond the point of corruption" when a column family was already flushed past it. PR 12403 therefore rejected `disableWAL` with recycling, PR 12639 exempted WritePrepared's internal split writes, and ingestion was never covered.

New behavior:
- `disableWAL` writes are accepted with `recycle_log_file_num > 0` for plain DBs and WriteCommitted and optimistic transaction DBs. WritePrepared and WriteUnprepared (`seq_per_batch`) still return `InvalidArgument`, exactly as before (with a message that now names them).
- Point-in-time recovery from recycled WALs no longer drops WAL data after sequence numbers consumed outside the WAL at a WAL boundary, whether by `disableWAL` writes, ingestion, or any other feature.
- Real corruption in a recycled WAL still stops recovery at the same point as before.

Implementation:
- `DBImpl` tracks `next_seq_after_last_wal_record_`: the sequence number recovery reaches after replaying the last WriteBatch successfully added to a WAL, i.e. its sequence plus the sequence numbers it consumes. `WriteToWAL()` and `WriteGroupToWAL()` take that count (`seq_inc` in `WriteImpl()` and `ConcurrentWriteGroupToWAL()`, `total_count` in `PipelinedWriteImpl()`, 0 for the `DB::Open` dummy entry). A failed WAL write sets it to 0 (unknown).
- Before the first WriteBatch of each WAL (`log::Writer::GetLastSeqnoRecorded() == 0`), `MaybeAddWalSeqnoGapFiller()` writes an empty WriteBatch whose sequence number is the expected one, if recycling is on, `seq_per_batch_` is false, the expected number is known, and the first WriteBatch skips ahead of it. Recovery's continuity check then compares against the filler instead of the first real WriteBatch. This is the same trick `DB::Open` already uses (an empty batch at the recovered sequence number) to keep point-in-time recovery working across WritePrepared gaps.
- The fix is entirely on the write side and keyed on what was actually written to the WAL, so it does not depend on auditing every feature that consumes sequence numbers, which was the concern in PR 12918. The recovery code is unchanged.
- The `InvalidArgument` check now applies only with `seq_per_batch_`. The crash-test workaround is removed.

Safety, compatibility, and limitations:
- Corruption detection: if corruption truncates WAL N (a record whose header log number is damaged looks like an old record; other damage fails the checksum), recovery ends WAL N below the filler's sequence number and stops, as it did when the next WAL started with a real WriteBatch. Detection power equals the existing continuity check; losing records that consume no sequence numbers (WriteCommitted prepares, empty batches) was never detected and still is not.
- Format: no new record type. The filler is a regular record holding an empty WriteBatch, which every RocksDB version reads, and older versions apply the same continuity check, so they also recover these WALs correctly after a downgrade. Fillers are written only with recycling on and a sequence gap at the start of a WAL, so WALs of existing workloads without such gaps are unchanged byte for byte.
- Safety invariant: a filler must never be below the sequence number recovery reaches after the previous WAL, or `CheckSeqnoNotSetBackDuringRecovery()` would fail `DB::Open`. Recovery reproduces sequence plus `seq_inc` for each WriteBatch without `seq_per_batch` (keys outside prepare sections, the prepared batch at a commit marker, reserved WBWI counts). Cases where recovery advances less (a `WalFilter` dropping entries, a commit marker whose prepare is gone) only make the filler larger than needed, which at worst falls back to the old stop-replay behavior. Fillers are skipped when the expected number is unknown, such as after a failed WAL write.
- Observable side effects: a `WalFilter` or `GetUpdatesSince()` can see an extra empty WriteBatch, as they already can for the `DB::Open` dummy entry. `GetUpdatesSince()` already reported such gaps as "Gap in sequence numbers".
- Performance: per WAL write group, one load and compare of the writer's last recorded sequence number (true once per WAL) plus one store; `disableWAL` writes are unchanged. See the benchmark below.
- Not covered: WritePrepared and WriteUnprepared keep the restriction. Their own internal unlogged writes (e.g. the commit publish write with two_write_queues) can already leave gaps at WAL boundaries under recycling; that pre-existing issue is unchanged here and needs follow-up. The crash test still defaults `recycle_log_file_num` to 0; enabling it at random is left to a follow-up after more stress runs.

Requested by: Jay Huh (jewoongh)

Differential Revision: D129451715
jaykorean added a commit to jaykorean/rocksdb that referenced this pull request Nov 9, 2026
Summary:

Why the change is required:
`WriteOptions::disableWAL` returns `Status::InvalidArgument` when `DBOptions::recycle_log_file_num > 0` (T185140603), and the crash test forces `recycle_log_file_num=0` whenever `disable_wal=1`. The root cause also loses data without disableWAL: external file ingestion consumes a sequence number without a WAL record, which is the recovery data loss reproduced by the disabled `DBWALTest.RecycleMultipleWalsCrash` (github PR 12918) and the reason WAL recycling is off in the crash test.

Previous behavior:
After a crash, a recycled WAL usually ends with records of its previous incarnation. In `kPointInTimeRecovery` the log reader reports such a record through `OldLogRecord()`. Since it cannot be told apart from a corrupted record, recovery stops replaying there and only continues into the next WAL if that WAL's first WriteBatch has exactly the sequence number recovery expects next (github PR 12403, D54544824). Any sequence numbers consumed between the last WriteBatch of one WAL and the first WriteBatch of the next without a WAL record (an unlogged write, an ingested file) fail that check, so recovery silently drops every later WAL, including acknowledged `sync` writes, or fails `DB::Open` with "SST file contains data beyond the point of corruption" when a column family was already flushed past it. PR 12403 therefore rejected `disableWAL` with recycling, PR 12639 exempted WritePrepared's internal split writes, and ingestion was never covered.

New behavior:
- `disableWAL` writes are accepted with `recycle_log_file_num > 0` for plain DBs and WriteCommitted and optimistic transaction DBs. WritePrepared and WriteUnprepared (`seq_per_batch`) still return `InvalidArgument`, exactly as before (with a message that now names them).
- Point-in-time recovery from recycled WALs no longer drops WAL data after sequence numbers consumed outside the WAL at a WAL boundary, whether by `disableWAL` writes, ingestion, or any other feature.
- Real corruption in a recycled WAL still stops recovery at the same point as before.

Implementation:
- `DBImpl` tracks `next_seq_after_last_wal_record_`: the sequence number recovery reaches after replaying the last WriteBatch successfully added to a WAL, i.e. its sequence plus the sequence numbers it consumes. `WriteToWAL()` and `WriteGroupToWAL()` take that count (`seq_inc` in `WriteImpl()` and `ConcurrentWriteGroupToWAL()`, `total_count` in `PipelinedWriteImpl()`, 0 for the `DB::Open` dummy entry). A failed WAL write sets it to 0 (unknown).
- Before the first WriteBatch of each WAL (`log::Writer::GetLastSeqnoRecorded() == 0`), `MaybeAddWalSeqnoGapFiller()` writes an empty WriteBatch whose sequence number is the expected one, if recycling is on, `seq_per_batch_` is false, the expected number is known, and the first WriteBatch skips ahead of it. Recovery's continuity check then compares against the filler instead of the first real WriteBatch. This is the same trick `DB::Open` already uses (an empty batch at the recovered sequence number) to keep point-in-time recovery working across WritePrepared gaps.
- The fix is entirely on the write side and keyed on what was actually written to the WAL, so it does not depend on auditing every feature that consumes sequence numbers, which was the concern in PR 12918. The recovery code is unchanged.
- The `InvalidArgument` check now applies only with `seq_per_batch_`. The crash-test workaround is removed.

Safety, compatibility, and limitations:
- Corruption detection: if corruption truncates WAL N (a record whose header log number is damaged looks like an old record; other damage fails the checksum), recovery ends WAL N below the filler's sequence number and stops, as it did when the next WAL started with a real WriteBatch. Detection power equals the existing continuity check; losing records that consume no sequence numbers (WriteCommitted prepares, empty batches) was never detected and still is not.
- Format: no new record type. The filler is a regular record holding an empty WriteBatch, which every RocksDB version reads, and older versions apply the same continuity check, so they also recover these WALs correctly after a downgrade. Fillers are written only with recycling on and a sequence gap at the start of a WAL, so WALs of existing workloads without such gaps are unchanged byte for byte.
- Safety invariant: a filler must never be below the sequence number recovery reaches after the previous WAL, or `CheckSeqnoNotSetBackDuringRecovery()` would fail `DB::Open`. Recovery reproduces sequence plus `seq_inc` for each WriteBatch without `seq_per_batch` (keys outside prepare sections, the prepared batch at a commit marker, reserved WBWI counts). Cases where recovery advances less (a `WalFilter` dropping entries, a commit marker whose prepare is gone) only make the filler larger than needed, which at worst falls back to the old stop-replay behavior. Fillers are skipped when the expected number is unknown, such as after a failed WAL write.
- Observable side effects: a `WalFilter` or `GetUpdatesSince()` can see an extra empty WriteBatch, as they already can for the `DB::Open` dummy entry. `GetUpdatesSince()` already reported such gaps as "Gap in sequence numbers".
- Performance: per WAL write group, one load and compare of the writer's last recorded sequence number (true once per WAL) plus one store; `disableWAL` writes are unchanged. See the benchmark below.
- Not covered: WritePrepared and WriteUnprepared keep the restriction. Their own internal unlogged writes (e.g. the commit publish write with two_write_queues) can already leave gaps at WAL boundaries under recycling; that pre-existing issue is unchanged here and needs follow-up. The crash test still defaults `recycle_log_file_num` to 0; enabling it at random is left to a follow-up after more stress runs.

Requested by: Jay Huh (jewoongh)

Differential Revision: D129451715
Summary:
Pull Request resolved: meta#15581

Why the change is required:
`WriteOptions::disableWAL` returns `Status::InvalidArgument` when `DBOptions::recycle_log_file_num > 0` (T185140603), and the crash test forces `recycle_log_file_num=0` whenever `disable_wal=1`. The root cause also loses data without disableWAL: external file ingestion consumes a sequence number without a WAL record, which is the recovery data loss reproduced by the disabled `DBWALTest.RecycleMultipleWalsCrash` (github PR 12918) and the reason WAL recycling is off in the crash test.

Previous behavior:
After a crash, a recycled WAL usually ends with records of its previous incarnation. In `kPointInTimeRecovery` the log reader reports such a record through `OldLogRecord()`. Since it cannot be told apart from a corrupted record, recovery stops replaying there and only continues into the next WAL if that WAL's first WriteBatch has exactly the sequence number recovery expects next (github PR 12403, D54544824). Any sequence numbers consumed between the last WriteBatch of one WAL and the first WriteBatch of the next without a WAL record (an unlogged write, an ingested file) fail that check, so recovery silently drops every later WAL, including acknowledged `sync` writes, or fails `DB::Open` with "SST file contains data beyond the point of corruption" when a column family was already flushed past it. PR 12403 therefore rejected `disableWAL` with recycling, PR 12639 exempted WritePrepared's internal split writes, and ingestion was never covered.

New behavior:
- `disableWAL` writes are accepted with `recycle_log_file_num > 0` for plain DBs and WriteCommitted and optimistic transaction DBs. WritePrepared and WriteUnprepared (`seq_per_batch`) still return `InvalidArgument`, exactly as before (with a message that now names them).
- Point-in-time recovery from recycled WALs no longer drops WAL data after sequence numbers consumed outside the WAL at a WAL boundary, whether by `disableWAL` writes, ingestion, or other features. A batch ending a WAL with a user `WriteBatch::MarkWalTerminationPoint()` keeps the old stop-replay behavior (see below).
- Real corruption in a recycled WAL still stops recovery at the same point as before.

Implementation:
- `DBImpl` tracks `next_seq_after_last_wal_record_`: the sequence number recovery reaches after replaying the last WriteBatch successfully added to a WAL, i.e. its sequence plus the sequence numbers it consumes. `WriteToWAL()` and `WriteGroupToWAL()` take that count (`seq_inc` in `WriteImpl()` and `ConcurrentWriteGroupToWAL()`, `total_count` in `PipelinedWriteImpl()`, 0 for the `DB::Open` dummy entry). A failed WAL write sets it to 0 (unknown).
- Before the first WriteBatch of each WAL (`log::Writer::GetLastSeqnoRecorded() == 0`), `MaybeAddWalSeqnoGapFiller()` writes an empty WriteBatch whose sequence number is the expected one, if recycling is on, `seq_per_batch_` is false, the expected number is known, and the first WriteBatch skips ahead of it. Recovery's continuity check then compares against the filler instead of the first real WriteBatch. This is the same trick `DB::Open` already uses (an empty batch at the recovered sequence number) to keep point-in-time recovery working across WritePrepared gaps.
- The fix is entirely on the write side and keyed on what was actually written to the WAL, so it does not depend on auditing every feature that consumes sequence numbers, which was the concern in PR 12918. The recovery code is unchanged.
- The `InvalidArgument` check now applies only with `seq_per_batch_`. The crash-test workaround is removed.

Safety, compatibility, and limitations:
- Corruption detection: if corruption truncates WAL N (a record whose header log number is damaged looks like an old record; other damage fails the checksum), recovery ends WAL N below the filler's sequence number and stops, as it did when the next WAL started with a real WriteBatch. Detection power equals the existing continuity check; losing records that consume no sequence numbers (WriteCommitted prepares, empty batches) was never detected and still is not.
- Format: no new record type. The filler is a regular record holding an empty WriteBatch, which every RocksDB version reads, and older versions apply the same continuity check, so they also recover these WALs correctly after a downgrade. Fillers are written only with recycling on and a sequence gap at the start of a WAL, so WALs of existing workloads without such gaps are unchanged byte for byte.
- Safety invariant: a filler must never be below the sequence number recovery reaches after the previous WAL, or `CheckSeqnoNotSetBackDuringRecovery()` would fail `DB::Open`. Recovery reproduces sequence plus `seq_inc` for each WriteBatch without `seq_per_batch` (keys outside prepare sections, the prepared batch at a commit marker, reserved WBWI counts). Cases where recovery advances less (a `WalFilter` dropping entries, a commit marker whose prepare is gone, a user WAL termination point that cuts keys from the logged batch) only make the filler larger than needed, which at worst falls back to the old stop-replay behavior. Fillers are skipped when the expected number is unknown, such as after a failed WAL write.
- Observable side effects: a `WalFilter` or `GetUpdatesSince()` can see an extra empty WriteBatch, as they already can for the `DB::Open` dummy entry. `GetUpdatesSince()` already reported such gaps as "Gap in sequence numbers".
- Performance: per WAL write group, one load and compare of the writer's last recorded sequence number (true once per WAL) plus one store; `disableWAL` writes are unchanged. See the benchmark below.
- Not covered: WritePrepared and WriteUnprepared keep the restriction. Their own internal unlogged writes (e.g. the commit publish write with two_write_queues) can already leave gaps at WAL boundaries under recycling; that pre-existing issue is unchanged here and needs follow-up. The crash test still defaults `recycle_log_file_num` to 0; enabling it at random is left to a follow-up after more stress runs.

Requested by: Jay Huh (jewoongh)

Reviewed By: xingbowang

Differential Revision: D129451715
@github-actions

Copy link
Copy Markdown

✅ Claude Code Review

Auto-triggered after CI passed — reviewing commit 4b147c8


Summary

Well-designed fix for a real recovery data-loss bug with recycled WALs and sequence-number gaps at WAL boundaries. The write-side-only approach using a gap filler is elegant, avoids modifying recovery code, and maintains format compatibility. Test coverage is thorough across write paths.

High-severity findings (0):
No high-severity findings.

Full review (click to expand)

Findings

🟡 MEDIUM

M1. Filler bytes not accounted in WAL size tracking -- db/db_impl/db_impl_write.cc:2387-2410
  • Issue: MaybeAddWalSeqnoGapFiller() calls log_writer->AddRecord() directly but the bytes it writes are not reflected in wals_total_size_ or wal_file_number_size.AddSize(). These are updated only for the main batch in WriteToWAL() (line ~2373-2374 pre-patch). The filler is small (~30 bytes with recyclable header), so the impact is minor, but it creates a discrepancy in WAL size tracking that feeds into max_total_wal_size enforcement and rate limiting.
  • Root cause: The filler is written in a helper called from WriteToWAL() before the main accounting block, and the accounting block only covers log_entry.size().
  • Suggested fix: After MaybeAddWalSeqnoGapFiller() returns OK, add the filler size to the size tracking, or document why the discrepancy is acceptable. Since the filler is written at most once per WAL and is tiny, documenting the choice may be sufficient.
M2. PipelinedWriteImpl counts only memtable-writing batches in total_count -- db/db_impl/db_impl_write.cc:1648-1654
  • Issue: In PipelinedWriteImpl, total_count sums WriteBatchInternal::Count() only for writers where ShouldWriteToMemtable() is true (line 1648). This total_count is now passed as seq_inc to WriteGroupToWAL. If a writer in the pipelined group has disable_memtable=true, its keys would not be counted in seq_inc, making next_seq_after_last_wal_record_ too low.
  • Root cause: Pre-existing: pipelined writes are incompatible with two_write_queues_ and seq_per_batch_, and disable_memtable is only used in those contexts (2PC WAL-only path). So in practice, ShouldWriteToMemtable() is always true in pipelined writes. However, this is an implicit invariant -- no assert guards it.
  • Suggested fix: This is low risk in practice but consider adding assert(!writer->disable_memtable) inside the pipelined write loop, or a comment documenting why ShouldWriteToMemtable is always true here. This would protect against future changes that might introduce disable_memtable into pipelined writes.

🟢 LOW / NIT

L1. DisableWalTruncationOnClose test helper leaks sync point state -- db/db_wal_test.cc:85-89
  • Issue: DisableWalTruncationOnClose() calls EnableProcessing() but relies on tests to call DisableProcessing() and ClearAllCallBacks() individually. If a test fails before cleanup, sync points leak to subsequent tests. The existing tests do clean up, but adding the cleanup to the test helper or using RAII would be more robust.
  • Suggested fix: Consider using SyncPoint::GetInstance()->DisableProcessing() in test teardown or an RAII guard, though the current approach matches existing patterns in the test file.
L2. Error message update is a minor behavioral compatibility change -- db/db_impl/db_impl_write.cc:943-946
  • Issue: The error message for the InvalidArgument return changed from "WriteOptions::disableWAL option is not supported if DBOptions::recycle_log_file_num > 0" to a message mentioning "WritePrepared or WriteUnprepared transactions". Any downstream code that matches on the error string would break. This is very unlikely but worth noting per behavioral compatibility guidelines.
  • Suggested fix: Acceptable as-is. Error message strings are not part of the stable API contract.
L3. CorruptRecycledWalRecord test helper uses magic offset 7 -- db/db_wal_test.cc:162
  • Issue: The comment says "The log number follows the checksum, length, and type in the header" and uses offset record_offset + 7. The constant 7 (4 bytes checksum + 2 bytes length + 1 byte type) is correct for the standard record header, but it should arguably use the named constants from log_format.h for maintainability.
  • Suggested fix: Consider using kHeaderSize - sizeof(uint32_t) or similar named constants, though the test-only context and clear comment make the magic number acceptable.

Cross-Component Analysis

Context Does code execute? Assumptions hold? Action needed?
WritePreparedTxnDB NO (rejected by seq_per_batch_ check) N/A Correctly excluded
WriteUnpreparedTxnDB NO (rejected by seq_per_batch_ check) N/A Correctly excluded
WriteCommitted 2PC (two_write_queues) YES YES -- WAL-only Prepare batches don't advance recovery sequence (verified via MemTableInserter with write_after_commit_=true in Prepare sections), so seq_inc=0 is correct Safe
ReadOnly DB NO (no writes) N/A Safe
Unordered write YES -- uses ConcurrentWriteGroupToWAL YES -- wal_write_mutex_ held Safe
Pipelined write YES -- uses WriteGroupToWAL YES -- single writer thread Safe
User-defined timestamps YES YES -- filler is a plain empty WriteBatch, no UDT issues Safe
WalFilter YES -- filter sees filler as extra empty batch Documented in PR as acceptable (same as DB::Open dummy) Safe
GetUpdatesSince YES -- sees filler batch Documented, same as existing gap behavior Safe
concurrent memtable write YES YES -- filler is on WAL path, not memtable Safe
DB::Open dummy batch YES -- next_seq_after_last_wal_record_ initialized to 0, filler skipped YES -- condition expected_seq == 0 prevents filler Safe
Older RocksDB versions (downgrade) YES -- filler is regular record YES -- continuity check still works Safe

Synchronization verification for next_seq_after_last_wal_record_:

  • Non-two_write_queues, non-manual_wal_flush: Single write thread (group leader) accesses WriteToWAL(). Safe.
  • two_write_queues: ConcurrentWriteGroupToWAL() holds wal_write_mutex_ before calling WriteToWAL(). Safe.
  • manual_wal_flush (without two_write_queues): WriteToWAL() acquires wal_write_mutex_ itself. Safe.

Key invariant verification:

  • Filler sequence >= recovery's next_sequence: The filler is written at next_seq_after_last_wal_record_ which tracks sequence + seq_inc of the last successful WAL write. Recovery advances next_sequence by the same amount for each replayed batch. So the filler exactly matches what recovery expects. Verified for all write paths (WriteImpl, PipelinedWriteImpl, ConcurrentWriteGroupToWAL, DB::Open).
  • Filler doesn't trigger CheckSeqnoNotSetBackDuringRecovery: The filler has Count() = 0, so recovery advances by 0 from the filler's sequence. Since filler sequence == previous WAL's final next_sequence, this is monotonically non-decreasing. Safe.
  • DB mutex not affected: MaybeAddWalSeqnoGapFiller() and the next_seq_after_last_wal_record_ tracking operate entirely within the WAL write path. They do not acquire or require DBImpl::mutex_. The synchronization is provided by the write thread model (single group leader) or wal_write_mutex_. No DB mutex performance impact.

Positive Observations

  • Write-side-only fix: By placing the fix entirely in the write path, the change avoids modifying the complex and well-tested recovery code. This significantly reduces risk.
  • Format compatibility: The filler uses an existing record format (regular WriteBatch), so older RocksDB versions can read these WALs without issues. No format version bump needed.
  • Thorough test coverage: Tests cover multiple write paths (default, concurrent WAL, pipelined, unordered), corruption detection, and WriteCommitted 2PC with both two_write_queues settings and commit_bypass_memtable.
  • Good test refactoring: Common helpers (DisableWalTruncationOnClose, PopulateWalsToRecycle, VerifyWalFilesToRecycle, CorruptRecycledWalRecord) reduce duplication and make the test code more maintainable.
  • Enabling previously disabled test: DISABLED_RecycleMultipleWalsCrash is re-enabled with the fix, confirming the bug that motivated the change is resolved.
  • Clear documentation: The WAL doc update and the comment on MaybeAddWalSeqnoGapFiller() clearly explain the mechanism and its limitations.

ℹ️ About this response

Generated by Claude Code.
Review methodology: claude_md/ci_review_prompt.md

Limitations:

  • Claude may miss context from files not in the diff
  • Large PRs may be truncated
  • Always apply human judgment to AI suggestions

Commands:

  • /claude-review [context] — Request a code review
  • /claude-query <question> — Ask about the PR or codebase

@meta-codesync meta-codesync Bot closed this in 536887e Nov 10, 2026
@meta-codesync meta-codesync Bot added the Merged label Nov 10, 2026
@meta-codesync

meta-codesync Bot commented Nov 10, 2026

Copy link
Copy Markdown

This pull request has been merged in 536887e.

JustinGaoF pushed a commit to JustinGaoF/rocksdb that referenced this pull request Nov 19, 2026
…n builds

Summary:
The flip of the PartitionWAL stack (GC18 Q1-Q5). DB::Open accepts
wal_partitions > 1 with an indexing partition_wal_usage in release and
debug builds, with no sync point and no opt-in. kNone with N>1 and every
other M1.4 rejection still fail with their exact Status. The
wal_partitions doc and the release notes describe the shipped behaviour
and the rollout order (readers first).

Removes:
- the N>1 gate in DBImpl::ValidateOptions and its debug sync point
  DBImpl::ValidateOptions:AllowWalPartitions;
- the GC13 opt-in experimental_allow_wal_partitions_for_testing
  (D-G18k (i)): the option, its OPTIONS-map entry, Dump line, generated C
  accessors (two "removed" entries are added to tools/c_api_gen/api_compatibility_allowlist.json); db_bench, db_stress and
  test::SetWalPartitions stop setting it;
- every use of the hook in tests and tools, including the hooks that
  tests folded below this commit carry at M4 (exception X14:
  FailedSyncPrepareLeavesNoStaleFence, GC23TimestampedSnapshotsSurviveFlushStress,
  GC19TornFirstRecordInBrandNewNTwoDbModes, CreateBrandNewPartitionedDb,
  GC23FloorOffForLaterGenerationHeads, GC24HistoryFloorScopeOnUpgrade) and
  the original hooks of SyncPrepareAfterSyncCommitSurvivesCrash,
  FU14SnapshotRace and FU14H6TornFirstRecordInBrandNewNTwoDb (GC26 Q5(d)).

Adds db_wal_partitions_open_test (GC18 Q1, with GC20 Q9's edits), GC20
Q9's "with indexing it opens" leg of WalPartitionsValidation (exception
X6), GC23 Q8's wal_partitions doc sentences (exception X6), and the
release notes unreleased_history/new_features/wal_partitions.md,
behavior_changes/partition_wal_sync_visibility.md (GC25) and
behavior_changes/partition_wal_recovery_modes.md (GC26) (exception X19:
they describe behaviour production builds reach only from this commit).

Recorded exception: this commit stays a standalone diff on top of the
stack and is never folded (GC18 round decision, design audit G3-C-2), so it
can be reviewed, landed and reverted alone, and N>1 never becomes legal
partway up the stack.

M5 fold: Absorbs 10 A.1 entries (GC28 1, GC27 3, GC30 2, GC29a 2, GC31 1, GC32 1): the five new release-note files (X19-M5); the post-flip wal_partitions doc lines (GC27, GC30, GC29a); wal_partitions.md. Exceptions: X19-M5. Release notes added here (X19-M5): bug_fixes/partition_wal_recovery_and_visibility_fixes.md, new_features/partition_wal_file_scoped_resume.md, performance_improvements/partition_wal_targeted_gate_sync.md, performance_improvements/partition_wal_write_path_locks.md, performance_improvements/partition_wal_write_pipeline.md. Removes the X14-M5 hook lines: the AllowWalPartitions callbacks D123079329, D123701876, D123928339, D123971668, D127093323 and D127275775 added to their folded N>1 tests.

M6 fold: removes the `DBImpl::ValidateOptions:AllowWalPartitions` hook lines added below the flip to the GC34 Q1 tests (`RunReplayedPrepareIsNotCut`); no other change.

Benchmark (rebased stack, paired and interleaved):

Release `db_bench` built at the rebased stack (fork f4c2cc3436 on facebook/rocksdb e732049; the final 7fd6043 differs only in transaction_test.cc). Workload: `fillrandom`, 3000 ops per thread, 4 KiB values, 64 column families, pipelined write off, auto compactions off, DB on /dev/shm. The latency-injection FileSystem adds a 200 us WAL append latency and a 200 us WAL sync latency (20 us jitter, fixed seed 1001). Profile S caps WAL append and sync bandwidth at 50 MB/s each. Profile S-sync caps only sync bandwidth (50 MB/s). There are three rounds, and each round runs every cell, rotating the cell order. The table reports the median of the three runs (min-max across runs). The ratio is the median of the per-round ratios against N=1 kNone. Host is shared: 1-minute load average 12-67 during the runs (other users). Sync column: `all` = `--sync`, `1-in-20` = `--sync_write_one_in=20`, `none` = no sync.

| Profile | Sync | Cell | ops/s (median of 3) | min-max | vs N=1 kNone | mean write us | p99 write us | WAL appends | WAL syncs |
|---|---|---|---|---|---|---|---|---|---|
| S | all | N=1 kNone | 5425 | 5282-5490 | 1.00x | 11646 | 13984 | 6002 | 6002 |
| S | all | N=1 indexed | 5374 | 4871-5456 | 0.98x | 11716 | 14528 | 6007 | 6005 |
| S | all | N=8 | 20104 | 20098-20516 | 3.71x | 3163 | 6351 | 90202 | 48470 |
| S | all | N=16 | 22746 | 21715-23222 | 4.14x | 2794 | 5075 | 133766 | 80580 |
| S | 1-in-20 | N=1 kNone | 5659 | 5645-5672 | 1.00x | 11283 | 58960 | 6149 | 2042 |
| S | 1-in-20 | N=1 indexed | 5669 | 5624-5680 | 1.00x | 11270 | 60891 | 6027 | 1916 |
| S | 1-in-20 | N=8 | 21635 | 20743-21835 | 3.81x | 2940 | 6587 | 63675 | 20851 |
| S | 1-in-20 | N=16 | 24240 | 23984-24506 | 4.29x | 2620 | 6208 | 105691 | 38739 |
| S | none | N=1 kNone | 10627 | 10435-10702 | 1.00x | 6015 | 6595 | 6005 | 0 |
| S | none | N=1 indexed | 10631 | 10433-10650 | 1.00x | 6012 | 6598 | 6007 | 0 |
| S | none | N=8 | 48068 | 47452-48281 | 4.52x | 1318 | 2788 | 48464 | 0 |
| S | none | N=16 | 63757 | 63551-63974 | 6.00x | 992 | 1881 | 83100 | 0 |
| S-sync | all | N=1 kNone | 9725 | 9722-9781 | 1.00x | 6570 | 9790 | 6003 | 6003 |
| S-sync | all | N=1 indexed | 9776 | 9770-9792 | 1.00x | 6539 | 9621 | 6006 | 6004 |
| S-sync | all | N=8 | 28877 | 27685-29180 | 2.97x | 2208 | 4214 | 88995 | 46361 |
| S-sync | all | N=16 | 27734 | 26727-29899 | 2.85x | 2292 | 4318 | 134123 | 78895 |
| S-sync | 1-in-20 | N=1 kNone | 10263 | 10190-10338 | 1.00x | 6220 | 19308 | 6029 | 2525 |
| S-sync | 1-in-20 | N=1 indexed | 10330 | 10159-10355 | 1.00x | 6180 | 28946 | 6029 | 2329 |
| S-sync | 1-in-20 | N=8 | 29514 | 29500-29519 | 2.88x | 2152 | 5876 | 61844 | 21538 |
| S-sync | 1-in-20 | N=16 | 30808 | 30736-31239 | 3.02x | 2059 | 4387 | 103682 | 39121 |
| S-sync | none | N=1 kNone | 72763 | 72596-74166 | 1.00x | 873 | 1293 | 6013 | 0 |
| S-sync | none | N=1 indexed | 74786 | 72987-75086 | 1.01x | 850 | 1285 | 6016 | 0 |
| S-sync | none | N=8 | 123028 | 120951-124222 | 1.67x | 512 | 862 | 39044 | 0 |
| S-sync | none | N=16 | 133228 | 129421-133491 | 1.80x | 471 | 855 | 71038 | 0 |
| S, 16 threads | all | N=1 kNone | 4724 | 4387-4738 | 1.00x | 3346 | 6482 | 4022 | 4022 |
| S, 16 threads | all | N=1 indexed | 4713 | 4707-4736 | 1.00x | 3334 | 6478 | 3958 | 3956 |
| S, 16 threads | all | N=8 | 8494 | 8464-8529 | 1.80x | 1873 | 2895 | 40476 | 27290 |
| S, 16 threads | all | N=16 | 9294 | 9250-9323 | 1.97x | 1711 | 2876 | 44226 | 34317 |

All 84 runs exited 0. Command per cell:

```
db_bench --benchmarks=fillrandom --threads=64 --num=3000 --value_size=4096 \
  --num_column_families=64 --wal_partitions=<N> --partition_wal_usage=<none|partition_by_column_family> \
  --enable_pipelined_write=false --disable_auto_compactions=1 --statistics --histogram \
  --inject_wal_latency --wal_append_latency_us=200 --wal_sync_latency_us=200 \
  --wal_latency_jitter_us=20 --wal_latency_seed=1001 --seed=1001 \
  --wal_append_bandwidth_mbps=<50|0> --wal_sync_bandwidth_mbps=50 [--sync | --sync_write_one_in=20]
```

N=1 against upstream (default options, no partitioning flags, no latency injection): release `db_bench` of this stack against release `db_bench` of facebook/rocksdb e732049, five rounds, alternating which binary runs first, DB on /dev/shm.

| Workload | upstream e732049 ops/s (median) | min-max | this stack ops/s (median) | min-max | stack/upstream (median of per-round) |
|---|---|---|---|---|---|
| fillrandom, 64 threads x 20000, 64 CFs, 4 KiB values, no sync | 224575 | 219463-232611 | 220572 | 213377-226176 | 0.972x |
| fillrandom, 16 threads x 200000, 1 KiB values, --sync | 532901 | 524086-611361 | 530771 | 525389-541405 | 0.999x |

Per-round stack/upstream ratios: --sync 0.996, 0.999, 1.032, 1.000, 0.860; no sync 0.972, 1.007, 0.948, 0.951, 0.990. 1-minute load average 11-22 during the runs. All 20 runs exited 0. The earlier run of the same comparison on e591f5f measured 0.996x (--sync) and 0.979x (no sync).

Stress (db_stress crash test with the latency-injection FileSystem wired in):

`tools/db_crashtest.py` blackbox and whitebox, 1800 s each, at wal_partitions 1 and 8, on the stack rebased onto facebook/rocksdb eb12834 (fork 286fdab796, debug db_stress; the final stack differs only in clang-format line wrapping and in `tools/db_crashtest.py`/`db_crashtest_test.py`). Pinned: `--disable_wal=0 --partition_wal_usage=partition_by_column_family --enable_blob_direct_write=0 --best_efforts_recovery=0 --two_write_queues=0 --enable_pipelined_write=0 --unordered_write=0 --recycle_log_file_num=0 --track_and_verify_wals=0 --inplace_update_support=0 --use_optimistic_txn=0`, plus `--inject_wal_latency=1 --wal_append_latency_us=50 --wal_sync_latency_us=300 --wal_latency_jitter_us=50 --wal_append_bandwidth_mbps=200 --wal_sync_bandwidth_mbps=100`. Every db_stress command line in the logs was checked for WAL on, latency injection on and the intended wal_partitions; randomized overrides did not disable them.

| Mode | wal_partitions | db_stress command lines | Result |
|---|---|---|---|
| blackbox | 1 | 31 | exit 0 |
| blackbox | 8 | 31 | exit 0 |
| whitebox | 1 | 16 | exit 0 |
| whitebox | 8 | 26 | exit 0 |

The same runs on the previous base (fork f4c2cc3436 on e732049) also exited 0 (31/31/22/12 command lines). The two fbcode sandcastle crash-test command lines that failed on the previous version (ASAN and blackbox, with `read_fault_one_in=1000`) were rerun locally against this stack, three times each for 1200 s: no failure.

fbcode sandcastle crash tests:

The six `rocksdb-contrun.sky` crash-test workflows ran on stack top 32fe728cb06b, scheduled 2026-11-10 05:32 UTC. The final stack differs from it only in test code, one comment and one line break (the ASAN and format fixes below); db_stress is unchanged. All six passed.

| Workflow | Result | Finished (PST, 2026-11-10) |
|---|---|---|
| fbcode_blackbox_crash_test | pass | 00:57 |
| fbcode_asan_blackbox_crash_test | pass | 00:57 |
| fbcode_tsan_blackbox_crash_test | pass | 01:16 |
| fbcode_whitebox_crash_test | pass | 03:37 |
| fbcode_asan_whitebox_crash_test | pass | 03:37 |
| fbcode_tsan_whitebox_crash_test | pass | 03:28 |

Sandcastle jobs: 49539596750420932, 49539596750421833, 40532397491966602, 49539596750421523, 45035997124599077, 22518001256897652 (https://www.internalfb.com/intern/sandcastle/job/<id>/). On the previous submitted version two of these workflows had failed (the sandcastle P1 below); that fix is in this stack.

Comprehensive review (15 rounds, whole 39-diff stack):

Each round ran the comprehensive-diff-review protocol (read-only Opus reviewers; round 1 used four reviewers by area, later rounds one) against the cumulative stack, on facebook/rocksdb d6a7847 for rounds 1-7 and, after the rebase onto e591f5f (the RocksDB subtree of fbcode/warm), on the rebased stack for rounds 8-11, on facebook/rocksdb e732049 (fbcode/warm 4df7e0a0db7b) for rounds 12-13, on 9ce1bfb (fbcode/warm 37d097c1b953) for round 14 and on eb12834 (fbcode/master b1d9881f429e) for round 15. Rounds 14 and 15 reviewed the rebase delta. Rows marked sandcastle, external and crash test are defects found outside the review rounds and fixed the same way. Every P1/P2 was re-checked against the code, reproduced by a new test that fails first, fixed in the diff that introduced the code, and verified by a neuter (reverting the fix makes the test fail). Candidates are the fork's review folds of pwal/m6.

| Round | Candidate | P1/P2 found | Fixed in | Regression test |
|---|---|---|---|---|
| 1 | pwal/m6 69c13fc | 4 P2: CMake missed db/log_merge.cc and log_merge_test; a secondary could not open or catch up beside an indexed primary with async_wal_precreate; a damaged first record in a WAL with an intact head floor and no span made the DB unopenable; commit_bypass_memtable failed after Prepare at N>1 | D120624825 (CMake), D127093323 (async_wal_precreate sanitized off when partition_wal_usage != kNone), D120649665 (HeadBounded counts the WAL's own head floor), D123079329 (bypass falls back to the memtable commit at N>1) | DBSecondaryTest.IndexedPrimaryDisablesAsyncWalPrecreate; DBWalPartitionCoverageTest.DamagedFirstRecordAfterUpgradeToTwoPartitions; TransactionPartitionedWalTest.CommitBypassMemtableCommitsNormally |
| 2 | fold2 2e8c56707a8f | 2 P2: GetSortedWalFiles returned a false Corruption once coupled rotation retired an idle partition's metadata-only WAL that the MANIFEST tracks; GC24HistoryFloorScopeOnUpgrade still pinned the pre-fix outcome | D127093323, D127837663 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWals |
| 3 | fold3 8b6590498 | 1 P2: that fix was keyed to the opener's wal_partitions, so read-only or N=1 openers still got the Corruption. Writing its test exposed a read-only open with WAL tracking off hitting `assert(recovery_ctx != nullptr)` in Recover; fixed too | D127093323 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWalsReadOnly |
| 4 | fold5 c3c369362 | 1 P2: at N=1 indexed, a data-less current WAL got a cached synthetic start sequence 1, so GetUpdatesSince skipped the older WAL holding the requested sequence | D127093323 | DBWalIteratorTest.IndexedDataLessCurrentWalKeepsOlderWal |
| 5 | fold6 6e3ad3889 | None. The per-diff gate then failed WalPartitions8/WritePreparedTransactionTest.{WC_WP_ForwardCompatibility, WP_WC_DBBackwardCompatibility}: listing every metadata-only WAL changed GetSortedWalFiles after a flush; reworked to upstream listing semantics | D127093323 | the two WritePrepared tests, unmodified |
| 6 | fold7 376fac935 | 1 P2: the rework left MANIFEST-tracked metadata-only WALs out of GetSortedWalFiles, so a GetLiveFiles(flush_memtable=false) + GetSortedWalFiles copy failed to open ("Missing WAL with log number"). Now a tracked metadata-only WAL is listed (start sequence 1, not cached) and an untracked one is skipped | D127093323 | DBWritePartitionTest.LiveFilesAndSortedWalFilesCopyOpens |
| 7 | fold8 431f2a98e | None (1 P3, below) | | |
| 8 | rebased 188e02204b43 (onto e591f5f; two reviewers) | None | | |
| sandcastle | previous submitted version | 1 P1 (fbcode crash tests with `read_fault_one_in=1000`): an injected WAL read I/O error during recovery surfaced as `Corruption: WAL index merge: WAL <n> head damaged and unattested` in the merged replay, and the classification pass ignored it | D120624825 (the merger keeps the read's IOError), D121636079/D121674557 (classification returns it), D123928339 (merged replay returns the merger's error before the damage checks) | LogMergeTest.FailedReadKeepsTheReadError; DBWALIndexTest.ClassificationReadIOErrorFailsRecovery; DBWalPartitionCoverageTest.MergeReadIOErrorFailsWithTheReadError |
| 9 | 805ea60 | 2 P3 + 1 gap, fixed: sequential indexed replay replaced the read IOError with a generic one; the merger's error dropped the read's retryable/data-loss/scope attributes | D120415420, D120624825 | DBWALIndexTest.SequentialIndexedReplayReadIOErrorKeepsTheReadError; LogMergeTest.FailedReadKeepsTheReadErrorAttributes |
| external | D119751506 reviewer comment | 1 P2: with manual_wal_flush the burned-index void cover appended to the WAL buffer without wal_write_mutex_, racing an application FlushWAL | D119751506 (takes the mutex as WriteToWAL does), D122412677 (per-partition mutex) | DBWALIndexTest.BurnedWALIndexCoverHoldsWALMutexWithManualFlush |
| crash test | 805ea60 | 1 P2 (debug only): whitebox crash test at N=8 hit the FlushScheduler::Empty consistency assertion when another partition leader dequeued concurrently | D123079329 (Empty reads the head under the debug checking mutex; release builds unchanged) | DBWritePartitionTest.FlushSchedulerEmptyRacesAnotherLeadersDequeue |
| 10 | 12aad1d | 1 P2: statuses on the merged-recovery read-error path left unchecked (ASSERT_STATUS_CHECKED abort) | D120624825, D123551605, D123701876, D123928339, D123971668, D127093323 (holders permitted, ignored reports marked) | the read-error tests above under ASSERT_STATUS_CHECKED |
| 11 | 69a91e9 | None | | |
| fbcode CI | previous submitted version | 1 P2 (build): D120624825 declared two private fields (`last_sequence_index_`, `last_sequence_wal_`) first used in D120649665, so clang failed with -Werror,-Wunused-private-field at D120624825 | D120624825 (the fields move to D120649665; later diffs unchanged) | clang per-diff build gate |
| 12 | f4c2cc3436 (rebased onto e732049) | 1 P2 (tests): upstream's new TransactionTest.InplaceUpdateSupportRequiresWriteCommitted also runs in this stack's WalPartitions8 instantiation, where Open rejects its options; 3 deterministic failures | D127275775 (at wal_partitions > 1 the test asserts NotSupported) | the test itself: 3 failures before, 33/33 after |
| 12 (re-review) | 7fd6043 | None | | |
| fbcode CI | 7fd6043 | 1 P2 (ASAN, test-only): GC31FollowerExitGroup freed its local Env while the fixture's last options still pointed at it, so the next DestroyAndReopen read freed memory (heap-use-after-free in NGreaterThan1FollowerExitHandsFailureToLeader); and the rocks format check flagged a comment over 80 columns and one unjoined condition | D123701876 (the helper resets the fixture's env on exit); D121858039, D123079329, D123551605, D123971668 (clang-format output) | the test under ASAN: heap-use-after-free before, 4/4 and db_write_test 581/581 after; check-format.sh passes on all 39 diffs |
| strict status | b19275b | 1 P2 (ASSERT_STATUS_CHECKED, GitHub CI): 27 aborts from unchecked statuses: a reader report superseded by a more specific recovery error, a per-record pending report on early returns, the gate sync's covered path, a background-error return, an ingestion early return, and three test-side cases. Release behaviour unchanged | D120415420, D120649665, D123476301, D123701876, D123928339, D123971668, D127837663 | the ASSERT_STATUS_CHECKED suite: 27 aborts before, 0 after |
| 13 | f658359 | None | | |
| 14 | m6-rb10 (rebased onto 9ce1bfb) | 1 P2 (tests, from my rebase resolution): upstream's new kSortedHash option config was not skipped at wal_partitions > 1, where Open accepts only the SkipList memtable, so 7 WalPartitions8/ExternalSSTFileTestN tests walking ChangeOptions failed to reopen | D127275775 (kSortedHash joins the N>1 skip list) | the 7 tests: fail before, pass after |
| 15 | 286fdab796 (rebased onto eb12834) | 1 P2 (crash test): upstream meta#15626 moved the inplace_update_support sanitizing ahead of this stack's N>1 overrides, which turned allow_concurrent_memtable_write back on, so about 3% of default crash-test series failed DB::Open. Found while verifying it: the same overrides replaced explicitly passed flags and made `make db_crashtest_tests` fail in about 5 of 6 runs, already on the previous stack (1 more P2) | D126533194 (N>1 steering moved into gen_cmd_params, before command-line flags) | db_crashtest_test.py: 3 new tests, each failing with the old overrides |
| 15 (re-review) | 0d68d5f821 | 2 P2 + 1 P3 in that fix: test_secondary was still drawn per run, so wal_partitions flipped between runs and a secondary could open over partition WALs; an explicit --wal_partitions was not steered; the new test helper did not pin the trie index (about 4% flaky) | D126533194 | test_wal_partitions_stays_fixed_across_runs, test_explicit_wal_partitions_is_steered (each fails under its neuter); suite 89/89 in 40 runs |
| fbcode CI | V1.2 drafts (1686cdb39f) | 1 P2 (stack order, crash test): D126533194 is the first diff whose crash test draws wal_partitions > 1, but the db_stress LockWAL check that accepts GetCurrentWalFile() NotSupported at N>1 lived in this diff, so whitebox runs at D126533194 failed with "GetCurrentWalFile() failed: Not implemented" | D126533194 (the check moves down from this diff; the final tree is unchanged) | local blackbox at wal_partitions=8, lock_wal_one_in=2000: the old D126533194 fails on its 2nd run (192 errors), the new one passes 11/11 |

Final state: all 39 diffs at fork 1686cdb39f on facebook/rocksdb eb12834, each mirrored byte-identically into its fbsource diff on fbcode/master b1d9881f429e (master has since gained one RocksDB commit, c043e8dfa272, touching include/rocksdb/options.h about 180 lines from this stack's hunks). At 286fdab796 (the final stack differs only in clang-format line wrapping and the crash-test Python): per-diff clang gate for all 39 diffs; full make suite 11192/11192; clang TSan once 709/709 and 100x 2600/2600; ASSERT_STATUS_CHECKED suite with no failures from this stack (range_locking_test only, below); crash tests above. At 1686cdb39f: db_write_test 581/581, the gap-filler tests, `tools/db_crashtest_test.py` 89/89, and fbcode/rocks/sandcastle/check-format.sh at every diff. Totals: 1 P1 and 20 P2 fixed.

Open items (P3 or validation gaps, tracked as follow-ups, not fixed here):
- ASSERT_STATUS_CHECKED: range_locking_test fails in that build mode at upstream e732049 too; it is not part of this stack.
- Rebase gap (pre-existing): with recycle_log_file_num > 0, an indexed one-partition DB gets no WAL sequence-gap filler (upstream meta#15581 covers kNone only), so an ingestion gap at a WAL boundary can still stop point-in-time recovery there, as it did for every DB before meta#15581.
- Round 9 F-002 (P3): consumer head checks report a WAL read I/O error as NotSupported.
- Round 11 gap (low confidence, pre-existing): the void re-read during recovery can swallow a transient read IOError.
- TSan with the gcc 11 runtime (libtsan.so.0) reports false "double lock of a mutex" on any std::condition_variable::wait_for mutex, upstream TransactionDB code included, because it does not intercept pthread_cond_clockwait. Use clang TSan.
- Round 7 P3: after an open that writes supersession records without a dummy write (for example a WalFilter stop with avoid_flush_during_recovery=true), partition 0's untracked, data-less current WAL carries the supersession record. GetSortedWalFiles skips it, so a GetLiveFiles + GetSortedWalFiles copy could fail with "two live records share index". Checkpoint and BackupEngine are unaffected. Inferred from code, not reproduced.
- Round 2 P3: WriteRecoverableState at N>1 can stamp the cached recoverable state inside an open fence during an auto-resumed retryable WAL error.
- Round 1 P3s: the checkpoint/backup LockWAL race tests can stop on an ASSERT before joining their threads; GC31FollowerExitGroup orders writers with sleeps; standalone db_stress at N>1 trips on the default get_current_wal_file_one_in; checkpoint/backup at N>1 wait out a write stop.
- Gaps: an indexed DB with wal_compression still caches start sequence 1 for a data-less WAL (as upstream does for compression-only WALs); HeadFloor() for a member with no surviving data is the last progress bound read (no production-reachable loss found).

Reports (MetaMate):
- Round 1: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-69c13fcb72e2-20261107t093444z
- Round 2: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold2-2e8c56707a8f-20261107t175411z
- Round 3: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold3-8b6590498-20261107t185930z
- Round 4: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold5-c3c369362-20261107t192653z
- Round 5: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold6-6e3ad3889-20261107t193256z
- Round 6: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold7-376fac935-20261108t054421z
- Round 7: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold8-431f2a98e-20261108t055310z
- Round 11: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb2-69a91e9ba-20261110t022328z
- Round 13: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb8-f6583590ed-20261110t195418z
- Round 15 (final stack): https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb15-1686cdb39f-20261111t191953z

Changes visible to existing users:
- Removes DBOptions::experimental_allow_wal_partitions_for_testing, its "experimental_allow_wal_partitions_for_testing" options-string key (which no longer parses) and the C API functions rocksdb_options_set/get_experimental_allow_wal_partitions_for_testing. All were added earlier in this stack (D117251769) and never released.
- The --wal_partitions help text of db_bench and db_stress changed.

Test Plan:
M4 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 4974 tests, 0 failed.

M5 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of compaction_service_test, db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_wal_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 7324 tests, 0 failed.

M6 B.1: PASS (debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7340/7340).

Rebased stack (e591f5f): PASS. Debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7559/7559. Full make suite 10540/10540.

Rebased stack (e732049, fbcode/warm 4df7e0a0db7b) final: clang per-diff gates for all 39 diffs; full make suite 10576/10579 at f4c2cc3436 with the 3 round-12 failures fixed at 7fd6043 (transaction_test 3475/3475); clang TSan; crash tests and the two sandcastle repro command lines above. At b19275b: db_write_test under ASAN/UBSAN (clang) 581/581; clang per-diff gates for D121858039 through D123971668 rerun and pass; fbcode/rocks/sandcastle/check-format.sh passes at every diff.
fbcode sandcastle crash tests (blackbox and whitebox; plain, ASAN, TSAN): 6/6 pass on 32fe728cb06b.
Strict status (ASSERT_STATUS_CHECKED=1) suite at f658359: 0 aborts from this stack (27 before the fix).
Rebased stack (facebook/rocksdb eb12834, fbcode/master b1d9881f429e) final: clang per-diff gates for all 39 diffs; full make suite 11192/11192; clang TSan 709/709 once and 2600/2600 at 100x; ASSERT_STATUS_CHECKED with only range_locking_test failing (not touched by this stack); crash tests blackbox and whitebox at wal_partitions 1 and 8 exit 0; `tools/db_crashtest_test.py` 89/89; check-format.sh passes at every diff.

Differential Revision: https://phabricator.intern.facebook.com/D130396596
JustinGaoF pushed a commit to JustinGaoF/rocksdb that referenced this pull request Nov 19, 2026
…n builds

Summary:
The flip of the PartitionWAL stack (GC18 Q1-Q5). DB::Open accepts
wal_partitions > 1 with an indexing partition_wal_usage in release and
debug builds, with no sync point and no opt-in. kNone with N>1 and every
other M1.4 rejection still fail with their exact Status. The
wal_partitions doc and the release notes describe the shipped behaviour
and the rollout order (readers first).

Removes:
- the N>1 gate in DBImpl::ValidateOptions and its debug sync point
  DBImpl::ValidateOptions:AllowWalPartitions;
- the GC13 opt-in experimental_allow_wal_partitions_for_testing
  (D-G18k (i)): the option, its OPTIONS-map entry, Dump line, generated C
  accessors (two "removed" entries are added to tools/c_api_gen/api_compatibility_allowlist.json); db_bench, db_stress and
  test::SetWalPartitions stop setting it;
- every use of the hook in tests and tools, including the hooks that
  tests folded below this commit carry at M4 (exception X14:
  FailedSyncPrepareLeavesNoStaleFence, GC23TimestampedSnapshotsSurviveFlushStress,
  GC19TornFirstRecordInBrandNewNTwoDbModes, CreateBrandNewPartitionedDb,
  GC23FloorOffForLaterGenerationHeads, GC24HistoryFloorScopeOnUpgrade) and
  the original hooks of SyncPrepareAfterSyncCommitSurvivesCrash,
  FU14SnapshotRace and FU14H6TornFirstRecordInBrandNewNTwoDb (GC26 Q5(d)).

Adds db_wal_partitions_open_test (GC18 Q1, with GC20 Q9's edits), GC20
Q9's "with indexing it opens" leg of WalPartitionsValidation (exception
X6), GC23 Q8's wal_partitions doc sentences (exception X6), and the
release notes unreleased_history/new_features/wal_partitions.md,
behavior_changes/partition_wal_sync_visibility.md (GC25) and
behavior_changes/partition_wal_recovery_modes.md (GC26) (exception X19:
they describe behaviour production builds reach only from this commit).

Recorded exception: this commit stays a standalone diff on top of the
stack and is never folded (GC18 round decision, design audit G3-C-2), so it
can be reviewed, landed and reverted alone, and N>1 never becomes legal
partway up the stack.

M5 fold: Absorbs 10 A.1 entries (GC28 1, GC27 3, GC30 2, GC29a 2, GC31 1, GC32 1): the five new release-note files (X19-M5); the post-flip wal_partitions doc lines (GC27, GC30, GC29a); wal_partitions.md. Exceptions: X19-M5. Release notes added here (X19-M5): bug_fixes/partition_wal_recovery_and_visibility_fixes.md, new_features/partition_wal_file_scoped_resume.md, performance_improvements/partition_wal_targeted_gate_sync.md, performance_improvements/partition_wal_write_path_locks.md, performance_improvements/partition_wal_write_pipeline.md. Removes the X14-M5 hook lines: the AllowWalPartitions callbacks D123079329, D123701876, D123928339, D123971668, D127093323 and D127275775 added to their folded N>1 tests.

M6 fold: removes the `DBImpl::ValidateOptions:AllowWalPartitions` hook lines added below the flip to the GC34 Q1 tests (`RunReplayedPrepareIsNotCut`); no other change.

Benchmark (rebased stack, paired and interleaved):

Release `db_bench` built at the rebased stack (fork f4c2cc3436 on facebook/rocksdb e732049; the final 7fd6043 differs only in transaction_test.cc). Workload: `fillrandom`, 3000 ops per thread, 4 KiB values, 64 column families, pipelined write off, auto compactions off, DB on /dev/shm. The latency-injection FileSystem adds a 200 us WAL append latency and a 200 us WAL sync latency (20 us jitter, fixed seed 1001). Profile S caps WAL append and sync bandwidth at 50 MB/s each. Profile S-sync caps only sync bandwidth (50 MB/s). There are three rounds, and each round runs every cell, rotating the cell order. The table reports the median of the three runs (min-max across runs). The ratio is the median of the per-round ratios against N=1 kNone. Host is shared: 1-minute load average 12-67 during the runs (other users). Sync column: `all` = `--sync`, `1-in-20` = `--sync_write_one_in=20`, `none` = no sync.

| Profile | Sync | Cell | ops/s (median of 3) | min-max | vs N=1 kNone | mean write us | p99 write us | WAL appends | WAL syncs |
|---|---|---|---|---|---|---|---|---|---|
| S | all | N=1 kNone | 5425 | 5282-5490 | 1.00x | 11646 | 13984 | 6002 | 6002 |
| S | all | N=1 indexed | 5374 | 4871-5456 | 0.98x | 11716 | 14528 | 6007 | 6005 |
| S | all | N=8 | 20104 | 20098-20516 | 3.71x | 3163 | 6351 | 90202 | 48470 |
| S | all | N=16 | 22746 | 21715-23222 | 4.14x | 2794 | 5075 | 133766 | 80580 |
| S | 1-in-20 | N=1 kNone | 5659 | 5645-5672 | 1.00x | 11283 | 58960 | 6149 | 2042 |
| S | 1-in-20 | N=1 indexed | 5669 | 5624-5680 | 1.00x | 11270 | 60891 | 6027 | 1916 |
| S | 1-in-20 | N=8 | 21635 | 20743-21835 | 3.81x | 2940 | 6587 | 63675 | 20851 |
| S | 1-in-20 | N=16 | 24240 | 23984-24506 | 4.29x | 2620 | 6208 | 105691 | 38739 |
| S | none | N=1 kNone | 10627 | 10435-10702 | 1.00x | 6015 | 6595 | 6005 | 0 |
| S | none | N=1 indexed | 10631 | 10433-10650 | 1.00x | 6012 | 6598 | 6007 | 0 |
| S | none | N=8 | 48068 | 47452-48281 | 4.52x | 1318 | 2788 | 48464 | 0 |
| S | none | N=16 | 63757 | 63551-63974 | 6.00x | 992 | 1881 | 83100 | 0 |
| S-sync | all | N=1 kNone | 9725 | 9722-9781 | 1.00x | 6570 | 9790 | 6003 | 6003 |
| S-sync | all | N=1 indexed | 9776 | 9770-9792 | 1.00x | 6539 | 9621 | 6006 | 6004 |
| S-sync | all | N=8 | 28877 | 27685-29180 | 2.97x | 2208 | 4214 | 88995 | 46361 |
| S-sync | all | N=16 | 27734 | 26727-29899 | 2.85x | 2292 | 4318 | 134123 | 78895 |
| S-sync | 1-in-20 | N=1 kNone | 10263 | 10190-10338 | 1.00x | 6220 | 19308 | 6029 | 2525 |
| S-sync | 1-in-20 | N=1 indexed | 10330 | 10159-10355 | 1.00x | 6180 | 28946 | 6029 | 2329 |
| S-sync | 1-in-20 | N=8 | 29514 | 29500-29519 | 2.88x | 2152 | 5876 | 61844 | 21538 |
| S-sync | 1-in-20 | N=16 | 30808 | 30736-31239 | 3.02x | 2059 | 4387 | 103682 | 39121 |
| S-sync | none | N=1 kNone | 72763 | 72596-74166 | 1.00x | 873 | 1293 | 6013 | 0 |
| S-sync | none | N=1 indexed | 74786 | 72987-75086 | 1.01x | 850 | 1285 | 6016 | 0 |
| S-sync | none | N=8 | 123028 | 120951-124222 | 1.67x | 512 | 862 | 39044 | 0 |
| S-sync | none | N=16 | 133228 | 129421-133491 | 1.80x | 471 | 855 | 71038 | 0 |
| S, 16 threads | all | N=1 kNone | 4724 | 4387-4738 | 1.00x | 3346 | 6482 | 4022 | 4022 |
| S, 16 threads | all | N=1 indexed | 4713 | 4707-4736 | 1.00x | 3334 | 6478 | 3958 | 3956 |
| S, 16 threads | all | N=8 | 8494 | 8464-8529 | 1.80x | 1873 | 2895 | 40476 | 27290 |
| S, 16 threads | all | N=16 | 9294 | 9250-9323 | 1.97x | 1711 | 2876 | 44226 | 34317 |

All 84 runs exited 0. Command per cell:

```
db_bench --benchmarks=fillrandom --threads=64 --num=3000 --value_size=4096 \
  --num_column_families=64 --wal_partitions=<N> --partition_wal_usage=<none|partition_by_column_family> \
  --enable_pipelined_write=false --disable_auto_compactions=1 --statistics --histogram \
  --inject_wal_latency --wal_append_latency_us=200 --wal_sync_latency_us=200 \
  --wal_latency_jitter_us=20 --wal_latency_seed=1001 --seed=1001 \
  --wal_append_bandwidth_mbps=<50|0> --wal_sync_bandwidth_mbps=50 [--sync | --sync_write_one_in=20]
```

N=1 against upstream (default options, no partitioning flags, no latency injection): release `db_bench` of this stack against release `db_bench` of facebook/rocksdb e732049, five rounds, alternating which binary runs first, DB on /dev/shm.

| Workload | upstream e732049 ops/s (median) | min-max | this stack ops/s (median) | min-max | stack/upstream (median of per-round) |
|---|---|---|---|---|---|
| fillrandom, 64 threads x 20000, 64 CFs, 4 KiB values, no sync | 224575 | 219463-232611 | 220572 | 213377-226176 | 0.972x |
| fillrandom, 16 threads x 200000, 1 KiB values, --sync | 532901 | 524086-611361 | 530771 | 525389-541405 | 0.999x |

Per-round stack/upstream ratios: --sync 0.996, 0.999, 1.032, 1.000, 0.860; no sync 0.972, 1.007, 0.948, 0.951, 0.990. 1-minute load average 11-22 during the runs. All 20 runs exited 0. The earlier run of the same comparison on e591f5f measured 0.996x (--sync) and 0.979x (no sync).

Stress (db_stress crash test with the latency-injection FileSystem wired in):

`tools/db_crashtest.py` blackbox and whitebox, 1800 s each, at wal_partitions 1 and 8, on the stack rebased onto facebook/rocksdb eb12834 (fork 286fdab796, debug db_stress; the final stack differs only in clang-format line wrapping and in `tools/db_crashtest.py`/`db_crashtest_test.py`). Pinned: `--disable_wal=0 --partition_wal_usage=partition_by_column_family --enable_blob_direct_write=0 --best_efforts_recovery=0 --two_write_queues=0 --enable_pipelined_write=0 --unordered_write=0 --recycle_log_file_num=0 --track_and_verify_wals=0 --inplace_update_support=0 --use_optimistic_txn=0`, plus `--inject_wal_latency=1 --wal_append_latency_us=50 --wal_sync_latency_us=300 --wal_latency_jitter_us=50 --wal_append_bandwidth_mbps=200 --wal_sync_bandwidth_mbps=100`. Every db_stress command line in the logs was checked for WAL on, latency injection on and the intended wal_partitions; randomized overrides did not disable them.

| Mode | wal_partitions | db_stress command lines | Result |
|---|---|---|---|
| blackbox | 1 | 31 | exit 0 |
| blackbox | 8 | 31 | exit 0 |
| whitebox | 1 | 16 | exit 0 |
| whitebox | 8 | 26 | exit 0 |

The same runs on the previous base (fork f4c2cc3436 on e732049) also exited 0 (31/31/22/12 command lines). The two fbcode sandcastle crash-test command lines that failed on the previous version (ASAN and blackbox, with `read_fault_one_in=1000`) were rerun locally against this stack, three times each for 1200 s: no failure.

fbcode sandcastle crash tests:

The six `rocksdb-contrun.sky` crash-test workflows ran on stack top 32fe728cb06b, scheduled 2026-11-10 05:32 UTC. The final stack differs from it only in test code, one comment and one line break (the ASAN and format fixes below); db_stress is unchanged. All six passed.

| Workflow | Result | Finished (PST, 2026-11-10) |
|---|---|---|
| fbcode_blackbox_crash_test | pass | 00:57 |
| fbcode_asan_blackbox_crash_test | pass | 00:57 |
| fbcode_tsan_blackbox_crash_test | pass | 01:16 |
| fbcode_whitebox_crash_test | pass | 03:37 |
| fbcode_asan_whitebox_crash_test | pass | 03:37 |
| fbcode_tsan_whitebox_crash_test | pass | 03:28 |

Sandcastle jobs: 49539596750420932, 49539596750421833, 40532397491966602, 49539596750421523, 45035997124599077, 22518001256897652 (https://www.internalfb.com/intern/sandcastle/job/<id>/). On the previous submitted version two of these workflows had failed (the sandcastle P1 below); that fix is in this stack.

Comprehensive review (15 rounds, whole 39-diff stack):

Each round ran the comprehensive-diff-review protocol (read-only Opus reviewers; round 1 used four reviewers by area, later rounds one) against the cumulative stack, on facebook/rocksdb d6a7847 for rounds 1-7 and, after the rebase onto e591f5f (the RocksDB subtree of fbcode/warm), on the rebased stack for rounds 8-11, on facebook/rocksdb e732049 (fbcode/warm 4df7e0a0db7b) for rounds 12-13, on 9ce1bfb (fbcode/warm 37d097c1b953) for round 14 and on eb12834 (fbcode/master b1d9881f429e) for round 15. Rounds 14 and 15 reviewed the rebase delta. Rows marked sandcastle, external and crash test are defects found outside the review rounds and fixed the same way. Every P1/P2 was re-checked against the code, reproduced by a new test that fails first, fixed in the diff that introduced the code, and verified by a neuter (reverting the fix makes the test fail). Candidates are the fork's review folds of pwal/m6.

| Round | Candidate | P1/P2 found | Fixed in | Regression test |
|---|---|---|---|---|
| 1 | pwal/m6 69c13fc | 4 P2: CMake missed db/log_merge.cc and log_merge_test; a secondary could not open or catch up beside an indexed primary with async_wal_precreate; a damaged first record in a WAL with an intact head floor and no span made the DB unopenable; commit_bypass_memtable failed after Prepare at N>1 | D120624825 (CMake), D127093323 (async_wal_precreate sanitized off when partition_wal_usage != kNone), D120649665 (HeadBounded counts the WAL's own head floor), D123079329 (bypass falls back to the memtable commit at N>1) | DBSecondaryTest.IndexedPrimaryDisablesAsyncWalPrecreate; DBWalPartitionCoverageTest.DamagedFirstRecordAfterUpgradeToTwoPartitions; TransactionPartitionedWalTest.CommitBypassMemtableCommitsNormally |
| 2 | fold2 2e8c56707a8f | 2 P2: GetSortedWalFiles returned a false Corruption once coupled rotation retired an idle partition's metadata-only WAL that the MANIFEST tracks; GC24HistoryFloorScopeOnUpgrade still pinned the pre-fix outcome | D127093323, D127837663 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWals |
| 3 | fold3 8b6590498 | 1 P2: that fix was keyed to the opener's wal_partitions, so read-only or N=1 openers still got the Corruption. Writing its test exposed a read-only open with WAL tracking off hitting `assert(recovery_ctx != nullptr)` in Recover; fixed too | D127093323 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWalsReadOnly |
| 4 | fold5 c3c369362 | 1 P2: at N=1 indexed, a data-less current WAL got a cached synthetic start sequence 1, so GetUpdatesSince skipped the older WAL holding the requested sequence | D127093323 | DBWalIteratorTest.IndexedDataLessCurrentWalKeepsOlderWal |
| 5 | fold6 6e3ad3889 | None. The per-diff gate then failed WalPartitions8/WritePreparedTransactionTest.{WC_WP_ForwardCompatibility, WP_WC_DBBackwardCompatibility}: listing every metadata-only WAL changed GetSortedWalFiles after a flush; reworked to upstream listing semantics | D127093323 | the two WritePrepared tests, unmodified |
| 6 | fold7 376fac935 | 1 P2: the rework left MANIFEST-tracked metadata-only WALs out of GetSortedWalFiles, so a GetLiveFiles(flush_memtable=false) + GetSortedWalFiles copy failed to open ("Missing WAL with log number"). Now a tracked metadata-only WAL is listed (start sequence 1, not cached) and an untracked one is skipped | D127093323 | DBWritePartitionTest.LiveFilesAndSortedWalFilesCopyOpens |
| 7 | fold8 431f2a98e | None (1 P3, below) | | |
| 8 | rebased 188e02204b43 (onto e591f5f; two reviewers) | None | | |
| sandcastle | previous submitted version | 1 P1 (fbcode crash tests with `read_fault_one_in=1000`): an injected WAL read I/O error during recovery surfaced as `Corruption: WAL index merge: WAL <n> head damaged and unattested` in the merged replay, and the classification pass ignored it | D120624825 (the merger keeps the read's IOError), D121636079/D121674557 (classification returns it), D123928339 (merged replay returns the merger's error before the damage checks) | LogMergeTest.FailedReadKeepsTheReadError; DBWALIndexTest.ClassificationReadIOErrorFailsRecovery; DBWalPartitionCoverageTest.MergeReadIOErrorFailsWithTheReadError |
| 9 | 805ea60 | 2 P3 + 1 gap, fixed: sequential indexed replay replaced the read IOError with a generic one; the merger's error dropped the read's retryable/data-loss/scope attributes | D120415420, D120624825 | DBWALIndexTest.SequentialIndexedReplayReadIOErrorKeepsTheReadError; LogMergeTest.FailedReadKeepsTheReadErrorAttributes |
| external | D119751506 reviewer comment | 1 P2: with manual_wal_flush the burned-index void cover appended to the WAL buffer without wal_write_mutex_, racing an application FlushWAL | D119751506 (takes the mutex as WriteToWAL does), D122412677 (per-partition mutex) | DBWALIndexTest.BurnedWALIndexCoverHoldsWALMutexWithManualFlush |
| crash test | 805ea60 | 1 P2 (debug only): whitebox crash test at N=8 hit the FlushScheduler::Empty consistency assertion when another partition leader dequeued concurrently | D123079329 (Empty reads the head under the debug checking mutex; release builds unchanged) | DBWritePartitionTest.FlushSchedulerEmptyRacesAnotherLeadersDequeue |
| 10 | 12aad1d | 1 P2: statuses on the merged-recovery read-error path left unchecked (ASSERT_STATUS_CHECKED abort) | D120624825, D123551605, D123701876, D123928339, D123971668, D127093323 (holders permitted, ignored reports marked) | the read-error tests above under ASSERT_STATUS_CHECKED |
| 11 | 69a91e9 | None | | |
| fbcode CI | previous submitted version | 1 P2 (build): D120624825 declared two private fields (`last_sequence_index_`, `last_sequence_wal_`) first used in D120649665, so clang failed with -Werror,-Wunused-private-field at D120624825 | D120624825 (the fields move to D120649665; later diffs unchanged) | clang per-diff build gate |
| 12 | f4c2cc3436 (rebased onto e732049) | 1 P2 (tests): upstream's new TransactionTest.InplaceUpdateSupportRequiresWriteCommitted also runs in this stack's WalPartitions8 instantiation, where Open rejects its options; 3 deterministic failures | D127275775 (at wal_partitions > 1 the test asserts NotSupported) | the test itself: 3 failures before, 33/33 after |
| 12 (re-review) | 7fd6043 | None | | |
| fbcode CI | 7fd6043 | 1 P2 (ASAN, test-only): GC31FollowerExitGroup freed its local Env while the fixture's last options still pointed at it, so the next DestroyAndReopen read freed memory (heap-use-after-free in NGreaterThan1FollowerExitHandsFailureToLeader); and the rocks format check flagged a comment over 80 columns and one unjoined condition | D123701876 (the helper resets the fixture's env on exit); D121858039, D123079329, D123551605, D123971668 (clang-format output) | the test under ASAN: heap-use-after-free before, 4/4 and db_write_test 581/581 after; check-format.sh passes on all 39 diffs |
| strict status | b19275b | 1 P2 (ASSERT_STATUS_CHECKED, GitHub CI): 27 aborts from unchecked statuses: a reader report superseded by a more specific recovery error, a per-record pending report on early returns, the gate sync's covered path, a background-error return, an ingestion early return, and three test-side cases. Release behaviour unchanged | D120415420, D120649665, D123476301, D123701876, D123928339, D123971668, D127837663 | the ASSERT_STATUS_CHECKED suite: 27 aborts before, 0 after |
| 13 | f658359 | None | | |
| 14 | m6-rb10 (rebased onto 9ce1bfb) | 1 P2 (tests, from my rebase resolution): upstream's new kSortedHash option config was not skipped at wal_partitions > 1, where Open accepts only the SkipList memtable, so 7 WalPartitions8/ExternalSSTFileTestN tests walking ChangeOptions failed to reopen | D127275775 (kSortedHash joins the N>1 skip list) | the 7 tests: fail before, pass after |
| 15 | 286fdab796 (rebased onto eb12834) | 1 P2 (crash test): upstream meta#15626 moved the inplace_update_support sanitizing ahead of this stack's N>1 overrides, which turned allow_concurrent_memtable_write back on, so about 3% of default crash-test series failed DB::Open. Found while verifying it: the same overrides replaced explicitly passed flags and made `make db_crashtest_tests` fail in about 5 of 6 runs, already on the previous stack (1 more P2) | D126533194 (N>1 steering moved into gen_cmd_params, before command-line flags) | db_crashtest_test.py: 3 new tests, each failing with the old overrides |
| 15 (re-review) | 0d68d5f821 | 2 P2 + 1 P3 in that fix: test_secondary was still drawn per run, so wal_partitions flipped between runs and a secondary could open over partition WALs; an explicit --wal_partitions was not steered; the new test helper did not pin the trie index (about 4% flaky) | D126533194 | test_wal_partitions_stays_fixed_across_runs, test_explicit_wal_partitions_is_steered (each fails under its neuter); suite 89/89 in 40 runs |
| fbcode CI | V1.2 drafts (1686cdb39f) | 1 P2 (stack order, crash test): D126533194 is the first diff whose crash test draws wal_partitions > 1, but the db_stress LockWAL check that accepts GetCurrentWalFile() NotSupported at N>1 lived in this diff, so whitebox runs at D126533194 failed with "GetCurrentWalFile() failed: Not implemented" | D126533194 (the check moves down from this diff; the final tree is unchanged) | local blackbox at wal_partitions=8, lock_wal_one_in=2000: the old D126533194 fails on its 2nd run (192 errors), the new one passes 11/11 |

Final state: all 39 diffs at fork 1686cdb39f on facebook/rocksdb eb12834, each mirrored byte-identically into its fbsource diff on fbcode/master b1d9881f429e (master has since gained one RocksDB commit, c043e8dfa272, touching include/rocksdb/options.h about 180 lines from this stack's hunks). At 286fdab796 (the final stack differs only in clang-format line wrapping and the crash-test Python): per-diff clang gate for all 39 diffs; full make suite 11192/11192; clang TSan once 709/709 and 100x 2600/2600; ASSERT_STATUS_CHECKED suite with no failures from this stack (range_locking_test only, below); crash tests above. At 1686cdb39f: db_write_test 581/581, the gap-filler tests, `tools/db_crashtest_test.py` 89/89, and fbcode/rocks/sandcastle/check-format.sh at every diff. Totals: 1 P1 and 20 P2 fixed.

Open items (P3 or validation gaps, tracked as follow-ups, not fixed here):
- ASSERT_STATUS_CHECKED: range_locking_test fails in that build mode at upstream e732049 too; it is not part of this stack.
- Rebase gap (pre-existing): with recycle_log_file_num > 0, an indexed one-partition DB gets no WAL sequence-gap filler (upstream meta#15581 covers kNone only), so an ingestion gap at a WAL boundary can still stop point-in-time recovery there, as it did for every DB before meta#15581.
- Round 9 F-002 (P3): consumer head checks report a WAL read I/O error as NotSupported.
- Round 11 gap (low confidence, pre-existing): the void re-read during recovery can swallow a transient read IOError.
- TSan with the gcc 11 runtime (libtsan.so.0) reports false "double lock of a mutex" on any std::condition_variable::wait_for mutex, upstream TransactionDB code included, because it does not intercept pthread_cond_clockwait. Use clang TSan.
- Round 7 P3: after an open that writes supersession records without a dummy write (for example a WalFilter stop with avoid_flush_during_recovery=true), partition 0's untracked, data-less current WAL carries the supersession record. GetSortedWalFiles skips it, so a GetLiveFiles + GetSortedWalFiles copy could fail with "two live records share index". Checkpoint and BackupEngine are unaffected. Inferred from code, not reproduced.
- Round 2 P3: WriteRecoverableState at N>1 can stamp the cached recoverable state inside an open fence during an auto-resumed retryable WAL error.
- Round 1 P3s: the checkpoint/backup LockWAL race tests can stop on an ASSERT before joining their threads; GC31FollowerExitGroup orders writers with sleeps; standalone db_stress at N>1 trips on the default get_current_wal_file_one_in; checkpoint/backup at N>1 wait out a write stop.
- Gaps: an indexed DB with wal_compression still caches start sequence 1 for a data-less WAL (as upstream does for compression-only WALs); HeadFloor() for a member with no surviving data is the last progress bound read (no production-reachable loss found).

Reports (MetaMate):
- Round 1: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-69c13fcb72e2-20261107t093444z
- Round 2: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold2-2e8c56707a8f-20261107t175411z
- Round 3: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold3-8b6590498-20261107t185930z
- Round 4: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold5-c3c369362-20261107t192653z
- Round 5: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold6-6e3ad3889-20261107t193256z
- Round 6: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold7-376fac935-20261108t054421z
- Round 7: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold8-431f2a98e-20261108t055310z
- Round 11: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb2-69a91e9ba-20261110t022328z
- Round 13: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb8-f6583590ed-20261110t195418z
- Round 15 (final stack): https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb15-1686cdb39f-20261111t191953z

Changes visible to existing users:
- Removes DBOptions::experimental_allow_wal_partitions_for_testing, its "experimental_allow_wal_partitions_for_testing" options-string key (which no longer parses) and the C API functions rocksdb_options_set/get_experimental_allow_wal_partitions_for_testing. All were added earlier in this stack (D117251769) and never released.
- The --wal_partitions help text of db_bench and db_stress changed.

Test Plan:
M4 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 4974 tests, 0 failed.

M5 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of compaction_service_test, db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_wal_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 7324 tests, 0 failed.

M6 B.1: PASS (debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7340/7340).

Rebased stack (e591f5f): PASS. Debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7559/7559. Full make suite 10540/10540.

Rebased stack (e732049, fbcode/warm 4df7e0a0db7b) final: clang per-diff gates for all 39 diffs; full make suite 10576/10579 at f4c2cc3436 with the 3 round-12 failures fixed at 7fd6043 (transaction_test 3475/3475); clang TSan; crash tests and the two sandcastle repro command lines above. At b19275b: db_write_test under ASAN/UBSAN (clang) 581/581; clang per-diff gates for D121858039 through D123971668 rerun and pass; fbcode/rocks/sandcastle/check-format.sh passes at every diff.
fbcode sandcastle crash tests (blackbox and whitebox; plain, ASAN, TSAN): 6/6 pass on 32fe728cb06b.
Strict status (ASSERT_STATUS_CHECKED=1) suite at f658359: 0 aborts from this stack (27 before the fix).
Rebased stack (facebook/rocksdb eb12834, fbcode/master b1d9881f429e) final: clang per-diff gates for all 39 diffs; full make suite 11192/11192; clang TSan 709/709 once and 2600/2600 at 100x; ASSERT_STATUS_CHECKED with only range_locking_test failing (not touched by this stack); crash tests blackbox and whitebox at wal_partitions 1 and 8 exit 0; `tools/db_crashtest_test.py` 89/89; check-format.sh passes at every diff.

Differential Revision: https://phabricator.intern.facebook.com/D130396596
JustinGaoF pushed a commit to JustinGaoF/rocksdb that referenced this pull request Nov 19, 2026
…n builds

Summary:
The flip of the PartitionWAL stack (GC18 Q1-Q5). DB::Open accepts
wal_partitions > 1 with an indexing partition_wal_usage in release and
debug builds, with no sync point and no opt-in. kNone with N>1 and every
other M1.4 rejection still fail with their exact Status. The
wal_partitions doc and the release notes describe the shipped behaviour
and the rollout order (readers first).

Removes:
- the N>1 gate in DBImpl::ValidateOptions and its debug sync point
  DBImpl::ValidateOptions:AllowWalPartitions;
- the GC13 opt-in experimental_allow_wal_partitions_for_testing
  (D-G18k (i)): the option, its OPTIONS-map entry, Dump line, generated C
  accessors (two "removed" entries are added to tools/c_api_gen/api_compatibility_allowlist.json); db_bench, db_stress and
  test::SetWalPartitions stop setting it;
- every use of the hook in tests and tools, including the hooks that
  tests folded below this commit carry at M4 (exception X14:
  FailedSyncPrepareLeavesNoStaleFence, GC23TimestampedSnapshotsSurviveFlushStress,
  GC19TornFirstRecordInBrandNewNTwoDbModes, CreateBrandNewPartitionedDb,
  GC23FloorOffForLaterGenerationHeads, GC24HistoryFloorScopeOnUpgrade) and
  the original hooks of SyncPrepareAfterSyncCommitSurvivesCrash,
  FU14SnapshotRace and FU14H6TornFirstRecordInBrandNewNTwoDb (GC26 Q5(d)).

Adds db_wal_partitions_open_test (GC18 Q1, with GC20 Q9's edits), GC20
Q9's "with indexing it opens" leg of WalPartitionsValidation (exception
X6), GC23 Q8's wal_partitions doc sentences (exception X6), and the
release notes unreleased_history/new_features/wal_partitions.md,
behavior_changes/partition_wal_sync_visibility.md (GC25) and
behavior_changes/partition_wal_recovery_modes.md (GC26) (exception X19:
they describe behaviour production builds reach only from this commit).

Recorded exception: this commit stays a standalone diff on top of the
stack and is never folded (GC18 round decision, design audit G3-C-2), so it
can be reviewed, landed and reverted alone, and N>1 never becomes legal
partway up the stack.

M5 fold: Absorbs 10 A.1 entries (GC28 1, GC27 3, GC30 2, GC29a 2, GC31 1, GC32 1): the five new release-note files (X19-M5); the post-flip wal_partitions doc lines (GC27, GC30, GC29a); wal_partitions.md. Exceptions: X19-M5. Release notes added here (X19-M5): bug_fixes/partition_wal_recovery_and_visibility_fixes.md, new_features/partition_wal_file_scoped_resume.md, performance_improvements/partition_wal_targeted_gate_sync.md, performance_improvements/partition_wal_write_path_locks.md, performance_improvements/partition_wal_write_pipeline.md. Removes the X14-M5 hook lines: the AllowWalPartitions callbacks D123079329, D123701876, D123928339, D123971668, D127093323 and D127275775 added to their folded N>1 tests.

M6 fold: removes the `DBImpl::ValidateOptions:AllowWalPartitions` hook lines added below the flip to the GC34 Q1 tests (`RunReplayedPrepareIsNotCut`); no other change.

Benchmark (rebased stack, paired and interleaved):

Release `db_bench` built at the rebased stack (fork f4c2cc3436 on facebook/rocksdb e732049; the final 7fd6043 differs only in transaction_test.cc). Workload: `fillrandom`, 3000 ops per thread, 4 KiB values, 64 column families, pipelined write off, auto compactions off, DB on /dev/shm. The latency-injection FileSystem adds a 200 us WAL append latency and a 200 us WAL sync latency (20 us jitter, fixed seed 1001). Profile S caps WAL append and sync bandwidth at 50 MB/s each. Profile S-sync caps only sync bandwidth (50 MB/s). There are three rounds, and each round runs every cell, rotating the cell order. The table reports the median of the three runs (min-max across runs). The ratio is the median of the per-round ratios against N=1 kNone. Host is shared: 1-minute load average 12-67 during the runs (other users). Sync column: `all` = `--sync`, `1-in-20` = `--sync_write_one_in=20`, `none` = no sync.

| Profile | Sync | Cell | ops/s (median of 3) | min-max | vs N=1 kNone | mean write us | p99 write us | WAL appends | WAL syncs |
|---|---|---|---|---|---|---|---|---|---|
| S | all | N=1 kNone | 5425 | 5282-5490 | 1.00x | 11646 | 13984 | 6002 | 6002 |
| S | all | N=1 indexed | 5374 | 4871-5456 | 0.98x | 11716 | 14528 | 6007 | 6005 |
| S | all | N=8 | 20104 | 20098-20516 | 3.71x | 3163 | 6351 | 90202 | 48470 |
| S | all | N=16 | 22746 | 21715-23222 | 4.14x | 2794 | 5075 | 133766 | 80580 |
| S | 1-in-20 | N=1 kNone | 5659 | 5645-5672 | 1.00x | 11283 | 58960 | 6149 | 2042 |
| S | 1-in-20 | N=1 indexed | 5669 | 5624-5680 | 1.00x | 11270 | 60891 | 6027 | 1916 |
| S | 1-in-20 | N=8 | 21635 | 20743-21835 | 3.81x | 2940 | 6587 | 63675 | 20851 |
| S | 1-in-20 | N=16 | 24240 | 23984-24506 | 4.29x | 2620 | 6208 | 105691 | 38739 |
| S | none | N=1 kNone | 10627 | 10435-10702 | 1.00x | 6015 | 6595 | 6005 | 0 |
| S | none | N=1 indexed | 10631 | 10433-10650 | 1.00x | 6012 | 6598 | 6007 | 0 |
| S | none | N=8 | 48068 | 47452-48281 | 4.52x | 1318 | 2788 | 48464 | 0 |
| S | none | N=16 | 63757 | 63551-63974 | 6.00x | 992 | 1881 | 83100 | 0 |
| S-sync | all | N=1 kNone | 9725 | 9722-9781 | 1.00x | 6570 | 9790 | 6003 | 6003 |
| S-sync | all | N=1 indexed | 9776 | 9770-9792 | 1.00x | 6539 | 9621 | 6006 | 6004 |
| S-sync | all | N=8 | 28877 | 27685-29180 | 2.97x | 2208 | 4214 | 88995 | 46361 |
| S-sync | all | N=16 | 27734 | 26727-29899 | 2.85x | 2292 | 4318 | 134123 | 78895 |
| S-sync | 1-in-20 | N=1 kNone | 10263 | 10190-10338 | 1.00x | 6220 | 19308 | 6029 | 2525 |
| S-sync | 1-in-20 | N=1 indexed | 10330 | 10159-10355 | 1.00x | 6180 | 28946 | 6029 | 2329 |
| S-sync | 1-in-20 | N=8 | 29514 | 29500-29519 | 2.88x | 2152 | 5876 | 61844 | 21538 |
| S-sync | 1-in-20 | N=16 | 30808 | 30736-31239 | 3.02x | 2059 | 4387 | 103682 | 39121 |
| S-sync | none | N=1 kNone | 72763 | 72596-74166 | 1.00x | 873 | 1293 | 6013 | 0 |
| S-sync | none | N=1 indexed | 74786 | 72987-75086 | 1.01x | 850 | 1285 | 6016 | 0 |
| S-sync | none | N=8 | 123028 | 120951-124222 | 1.67x | 512 | 862 | 39044 | 0 |
| S-sync | none | N=16 | 133228 | 129421-133491 | 1.80x | 471 | 855 | 71038 | 0 |
| S, 16 threads | all | N=1 kNone | 4724 | 4387-4738 | 1.00x | 3346 | 6482 | 4022 | 4022 |
| S, 16 threads | all | N=1 indexed | 4713 | 4707-4736 | 1.00x | 3334 | 6478 | 3958 | 3956 |
| S, 16 threads | all | N=8 | 8494 | 8464-8529 | 1.80x | 1873 | 2895 | 40476 | 27290 |
| S, 16 threads | all | N=16 | 9294 | 9250-9323 | 1.97x | 1711 | 2876 | 44226 | 34317 |

All 84 runs exited 0. Command per cell:

```
db_bench --benchmarks=fillrandom --threads=64 --num=3000 --value_size=4096 \
  --num_column_families=64 --wal_partitions=<N> --partition_wal_usage=<none|partition_by_column_family> \
  --enable_pipelined_write=false --disable_auto_compactions=1 --statistics --histogram \
  --inject_wal_latency --wal_append_latency_us=200 --wal_sync_latency_us=200 \
  --wal_latency_jitter_us=20 --wal_latency_seed=1001 --seed=1001 \
  --wal_append_bandwidth_mbps=<50|0> --wal_sync_bandwidth_mbps=50 [--sync | --sync_write_one_in=20]
```

N=1 against upstream (default options, no partitioning flags, no latency injection): release `db_bench` of this stack against release `db_bench` of facebook/rocksdb e732049, five rounds, alternating which binary runs first, DB on /dev/shm.

| Workload | upstream e732049 ops/s (median) | min-max | this stack ops/s (median) | min-max | stack/upstream (median of per-round) |
|---|---|---|---|---|---|
| fillrandom, 64 threads x 20000, 64 CFs, 4 KiB values, no sync | 224575 | 219463-232611 | 220572 | 213377-226176 | 0.972x |
| fillrandom, 16 threads x 200000, 1 KiB values, --sync | 532901 | 524086-611361 | 530771 | 525389-541405 | 0.999x |

Per-round stack/upstream ratios: --sync 0.996, 0.999, 1.032, 1.000, 0.860; no sync 0.972, 1.007, 0.948, 0.951, 0.990. 1-minute load average 11-22 during the runs. All 20 runs exited 0. The earlier run of the same comparison on e591f5f measured 0.996x (--sync) and 0.979x (no sync).

Stress (db_stress crash test with the latency-injection FileSystem wired in):

`tools/db_crashtest.py` blackbox and whitebox, 1800 s each, at wal_partitions 1 and 8, on the stack rebased onto facebook/rocksdb eb12834 (fork 286fdab796, debug db_stress; the final stack differs only in clang-format line wrapping and in `tools/db_crashtest.py`/`db_crashtest_test.py`). Pinned: `--disable_wal=0 --partition_wal_usage=partition_by_column_family --enable_blob_direct_write=0 --best_efforts_recovery=0 --two_write_queues=0 --enable_pipelined_write=0 --unordered_write=0 --recycle_log_file_num=0 --track_and_verify_wals=0 --inplace_update_support=0 --use_optimistic_txn=0`, plus `--inject_wal_latency=1 --wal_append_latency_us=50 --wal_sync_latency_us=300 --wal_latency_jitter_us=50 --wal_append_bandwidth_mbps=200 --wal_sync_bandwidth_mbps=100`. Every db_stress command line in the logs was checked for WAL on, latency injection on and the intended wal_partitions; randomized overrides did not disable them.

| Mode | wal_partitions | db_stress command lines | Result |
|---|---|---|---|
| blackbox | 1 | 31 | exit 0 |
| blackbox | 8 | 31 | exit 0 |
| whitebox | 1 | 16 | exit 0 |
| whitebox | 8 | 26 | exit 0 |

The same runs on the previous base (fork f4c2cc3436 on e732049) also exited 0 (31/31/22/12 command lines). The two fbcode sandcastle crash-test command lines that failed on the previous version (ASAN and blackbox, with `read_fault_one_in=1000`) were rerun locally against this stack, three times each for 1200 s: no failure.

fbcode sandcastle crash tests:

The six `rocksdb-contrun.sky` crash-test workflows ran on stack top 32fe728cb06b, scheduled 2026-11-10 05:32 UTC. The final stack differs from it only in test code, one comment and one line break (the ASAN and format fixes below); db_stress is unchanged. All six passed.

| Workflow | Result | Finished (PST, 2026-11-10) |
|---|---|---|
| fbcode_blackbox_crash_test | pass | 00:57 |
| fbcode_asan_blackbox_crash_test | pass | 00:57 |
| fbcode_tsan_blackbox_crash_test | pass | 01:16 |
| fbcode_whitebox_crash_test | pass | 03:37 |
| fbcode_asan_whitebox_crash_test | pass | 03:37 |
| fbcode_tsan_whitebox_crash_test | pass | 03:28 |

Sandcastle jobs: 49539596750420932, 49539596750421833, 40532397491966602, 49539596750421523, 45035997124599077, 22518001256897652 (https://www.internalfb.com/intern/sandcastle/job/<id>/). On the previous submitted version two of these workflows had failed (the sandcastle P1 below); that fix is in this stack.

Comprehensive review (15 rounds, whole 39-diff stack):

Each round ran the comprehensive-diff-review protocol (read-only Opus reviewers; round 1 used four reviewers by area, later rounds one) against the cumulative stack, on facebook/rocksdb d6a7847 for rounds 1-7 and, after the rebase onto e591f5f (the RocksDB subtree of fbcode/warm), on the rebased stack for rounds 8-11, on facebook/rocksdb e732049 (fbcode/warm 4df7e0a0db7b) for rounds 12-13, on 9ce1bfb (fbcode/warm 37d097c1b953) for round 14 and on eb12834 (fbcode/master b1d9881f429e) for round 15. Rounds 14 and 15 reviewed the rebase delta. Rows marked sandcastle, external and crash test are defects found outside the review rounds and fixed the same way. Every P1/P2 was re-checked against the code, reproduced by a new test that fails first, fixed in the diff that introduced the code, and verified by a neuter (reverting the fix makes the test fail). Candidates are the fork's review folds of pwal/m6.

| Round | Candidate | P1/P2 found | Fixed in | Regression test |
|---|---|---|---|---|
| 1 | pwal/m6 69c13fc | 4 P2: CMake missed db/log_merge.cc and log_merge_test; a secondary could not open or catch up beside an indexed primary with async_wal_precreate; a damaged first record in a WAL with an intact head floor and no span made the DB unopenable; commit_bypass_memtable failed after Prepare at N>1 | D120624825 (CMake), D127093323 (async_wal_precreate sanitized off when partition_wal_usage != kNone), D120649665 (HeadBounded counts the WAL's own head floor), D123079329 (bypass falls back to the memtable commit at N>1) | DBSecondaryTest.IndexedPrimaryDisablesAsyncWalPrecreate; DBWalPartitionCoverageTest.DamagedFirstRecordAfterUpgradeToTwoPartitions; TransactionPartitionedWalTest.CommitBypassMemtableCommitsNormally |
| 2 | fold2 2e8c56707a8f | 2 P2: GetSortedWalFiles returned a false Corruption once coupled rotation retired an idle partition's metadata-only WAL that the MANIFEST tracks; GC24HistoryFloorScopeOnUpgrade still pinned the pre-fix outcome | D127093323, D127837663 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWals |
| 3 | fold3 8b6590498 | 1 P2: that fix was keyed to the opener's wal_partitions, so read-only or N=1 openers still got the Corruption. Writing its test exposed a read-only open with WAL tracking off hitting `assert(recovery_ctx != nullptr)` in Recover; fixed too | D127093323 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWalsReadOnly |
| 4 | fold5 c3c369362 | 1 P2: at N=1 indexed, a data-less current WAL got a cached synthetic start sequence 1, so GetUpdatesSince skipped the older WAL holding the requested sequence | D127093323 | DBWalIteratorTest.IndexedDataLessCurrentWalKeepsOlderWal |
| 5 | fold6 6e3ad3889 | None. The per-diff gate then failed WalPartitions8/WritePreparedTransactionTest.{WC_WP_ForwardCompatibility, WP_WC_DBBackwardCompatibility}: listing every metadata-only WAL changed GetSortedWalFiles after a flush; reworked to upstream listing semantics | D127093323 | the two WritePrepared tests, unmodified |
| 6 | fold7 376fac935 | 1 P2: the rework left MANIFEST-tracked metadata-only WALs out of GetSortedWalFiles, so a GetLiveFiles(flush_memtable=false) + GetSortedWalFiles copy failed to open ("Missing WAL with log number"). Now a tracked metadata-only WAL is listed (start sequence 1, not cached) and an untracked one is skipped | D127093323 | DBWritePartitionTest.LiveFilesAndSortedWalFilesCopyOpens |
| 7 | fold8 431f2a98e | None (1 P3, below) | | |
| 8 | rebased 188e02204b43 (onto e591f5f; two reviewers) | None | | |
| sandcastle | previous submitted version | 1 P1 (fbcode crash tests with `read_fault_one_in=1000`): an injected WAL read I/O error during recovery surfaced as `Corruption: WAL index merge: WAL <n> head damaged and unattested` in the merged replay, and the classification pass ignored it | D120624825 (the merger keeps the read's IOError), D121636079/D121674557 (classification returns it), D123928339 (merged replay returns the merger's error before the damage checks) | LogMergeTest.FailedReadKeepsTheReadError; DBWALIndexTest.ClassificationReadIOErrorFailsRecovery; DBWalPartitionCoverageTest.MergeReadIOErrorFailsWithTheReadError |
| 9 | 805ea60 | 2 P3 + 1 gap, fixed: sequential indexed replay replaced the read IOError with a generic one; the merger's error dropped the read's retryable/data-loss/scope attributes | D120415420, D120624825 | DBWALIndexTest.SequentialIndexedReplayReadIOErrorKeepsTheReadError; LogMergeTest.FailedReadKeepsTheReadErrorAttributes |
| external | D119751506 reviewer comment | 1 P2: with manual_wal_flush the burned-index void cover appended to the WAL buffer without wal_write_mutex_, racing an application FlushWAL | D119751506 (takes the mutex as WriteToWAL does), D122412677 (per-partition mutex) | DBWALIndexTest.BurnedWALIndexCoverHoldsWALMutexWithManualFlush |
| crash test | 805ea60 | 1 P2 (debug only): whitebox crash test at N=8 hit the FlushScheduler::Empty consistency assertion when another partition leader dequeued concurrently | D123079329 (Empty reads the head under the debug checking mutex; release builds unchanged) | DBWritePartitionTest.FlushSchedulerEmptyRacesAnotherLeadersDequeue |
| 10 | 12aad1d | 1 P2: statuses on the merged-recovery read-error path left unchecked (ASSERT_STATUS_CHECKED abort) | D120624825, D123551605, D123701876, D123928339, D123971668, D127093323 (holders permitted, ignored reports marked) | the read-error tests above under ASSERT_STATUS_CHECKED |
| 11 | 69a91e9 | None | | |
| fbcode CI | previous submitted version | 1 P2 (build): D120624825 declared two private fields (`last_sequence_index_`, `last_sequence_wal_`) first used in D120649665, so clang failed with -Werror,-Wunused-private-field at D120624825 | D120624825 (the fields move to D120649665; later diffs unchanged) | clang per-diff build gate |
| 12 | f4c2cc3436 (rebased onto e732049) | 1 P2 (tests): upstream's new TransactionTest.InplaceUpdateSupportRequiresWriteCommitted also runs in this stack's WalPartitions8 instantiation, where Open rejects its options; 3 deterministic failures | D127275775 (at wal_partitions > 1 the test asserts NotSupported) | the test itself: 3 failures before, 33/33 after |
| 12 (re-review) | 7fd6043 | None | | |
| fbcode CI | 7fd6043 | 1 P2 (ASAN, test-only): GC31FollowerExitGroup freed its local Env while the fixture's last options still pointed at it, so the next DestroyAndReopen read freed memory (heap-use-after-free in NGreaterThan1FollowerExitHandsFailureToLeader); and the rocks format check flagged a comment over 80 columns and one unjoined condition | D123701876 (the helper resets the fixture's env on exit); D121858039, D123079329, D123551605, D123971668 (clang-format output) | the test under ASAN: heap-use-after-free before, 4/4 and db_write_test 581/581 after; check-format.sh passes on all 39 diffs |
| strict status | b19275b | 1 P2 (ASSERT_STATUS_CHECKED, GitHub CI): 27 aborts from unchecked statuses: a reader report superseded by a more specific recovery error, a per-record pending report on early returns, the gate sync's covered path, a background-error return, an ingestion early return, and three test-side cases. Release behaviour unchanged | D120415420, D120649665, D123476301, D123701876, D123928339, D123971668, D127837663 | the ASSERT_STATUS_CHECKED suite: 27 aborts before, 0 after |
| 13 | f658359 | None | | |
| 14 | m6-rb10 (rebased onto 9ce1bfb) | 1 P2 (tests, from my rebase resolution): upstream's new kSortedHash option config was not skipped at wal_partitions > 1, where Open accepts only the SkipList memtable, so 7 WalPartitions8/ExternalSSTFileTestN tests walking ChangeOptions failed to reopen | D127275775 (kSortedHash joins the N>1 skip list) | the 7 tests: fail before, pass after |
| 15 | 286fdab796 (rebased onto eb12834) | 1 P2 (crash test): upstream meta#15626 moved the inplace_update_support sanitizing ahead of this stack's N>1 overrides, which turned allow_concurrent_memtable_write back on, so about 3% of default crash-test series failed DB::Open. Found while verifying it: the same overrides replaced explicitly passed flags and made `make db_crashtest_tests` fail in about 5 of 6 runs, already on the previous stack (1 more P2) | D126533194 (N>1 steering moved into gen_cmd_params, before command-line flags) | db_crashtest_test.py: 3 new tests, each failing with the old overrides |
| 15 (re-review) | 0d68d5f821 | 2 P2 + 1 P3 in that fix: test_secondary was still drawn per run, so wal_partitions flipped between runs and a secondary could open over partition WALs; an explicit --wal_partitions was not steered; the new test helper did not pin the trie index (about 4% flaky) | D126533194 | test_wal_partitions_stays_fixed_across_runs, test_explicit_wal_partitions_is_steered (each fails under its neuter); suite 89/89 in 40 runs |
| fbcode CI | V1.2 drafts (1686cdb39f) | 1 P2 (stack order, crash test): D126533194 is the first diff whose crash test draws wal_partitions > 1, but the db_stress LockWAL check that accepts GetCurrentWalFile() NotSupported at N>1 lived in this diff, so whitebox runs at D126533194 failed with "GetCurrentWalFile() failed: Not implemented" | D126533194 (the check moves down from this diff; the final tree is unchanged) | local blackbox at wal_partitions=8, lock_wal_one_in=2000: the old D126533194 fails on its 2nd run (192 errors), the new one passes 11/11 |

Final state: all 39 diffs at fork 1686cdb39f on facebook/rocksdb eb12834, each mirrored byte-identically into its fbsource diff on fbcode/master b1d9881f429e (master has since gained one RocksDB commit, c043e8dfa272, touching include/rocksdb/options.h about 180 lines from this stack's hunks). At 286fdab796 (the final stack differs only in clang-format line wrapping and the crash-test Python): per-diff clang gate for all 39 diffs; full make suite 11192/11192; clang TSan once 709/709 and 100x 2600/2600; ASSERT_STATUS_CHECKED suite with no failures from this stack (range_locking_test only, below); crash tests above. At 1686cdb39f: db_write_test 581/581, the gap-filler tests, `tools/db_crashtest_test.py` 89/89, and fbcode/rocks/sandcastle/check-format.sh at every diff. Totals: 1 P1 and 20 P2 fixed.

Open items (P3 or validation gaps, tracked as follow-ups, not fixed here):
- ASSERT_STATUS_CHECKED: range_locking_test fails in that build mode at upstream e732049 too; it is not part of this stack.
- Rebase gap (pre-existing): with recycle_log_file_num > 0, an indexed one-partition DB gets no WAL sequence-gap filler (upstream meta#15581 covers kNone only), so an ingestion gap at a WAL boundary can still stop point-in-time recovery there, as it did for every DB before meta#15581.
- Round 9 F-002 (P3): consumer head checks report a WAL read I/O error as NotSupported.
- Round 11 gap (low confidence, pre-existing): the void re-read during recovery can swallow a transient read IOError.
- TSan with the gcc 11 runtime (libtsan.so.0) reports false "double lock of a mutex" on any std::condition_variable::wait_for mutex, upstream TransactionDB code included, because it does not intercept pthread_cond_clockwait. Use clang TSan.
- Round 7 P3: after an open that writes supersession records without a dummy write (for example a WalFilter stop with avoid_flush_during_recovery=true), partition 0's untracked, data-less current WAL carries the supersession record. GetSortedWalFiles skips it, so a GetLiveFiles + GetSortedWalFiles copy could fail with "two live records share index". Checkpoint and BackupEngine are unaffected. Inferred from code, not reproduced.
- Round 2 P3: WriteRecoverableState at N>1 can stamp the cached recoverable state inside an open fence during an auto-resumed retryable WAL error.
- Round 1 P3s: the checkpoint/backup LockWAL race tests can stop on an ASSERT before joining their threads; GC31FollowerExitGroup orders writers with sleeps; standalone db_stress at N>1 trips on the default get_current_wal_file_one_in; checkpoint/backup at N>1 wait out a write stop.
- Gaps: an indexed DB with wal_compression still caches start sequence 1 for a data-less WAL (as upstream does for compression-only WALs); HeadFloor() for a member with no surviving data is the last progress bound read (no production-reachable loss found).

Reports (MetaMate):
- Round 1: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-69c13fcb72e2-20261107t093444z
- Round 2: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold2-2e8c56707a8f-20261107t175411z
- Round 3: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold3-8b6590498-20261107t185930z
- Round 4: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold5-c3c369362-20261107t192653z
- Round 5: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold6-6e3ad3889-20261107t193256z
- Round 6: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold7-376fac935-20261108t054421z
- Round 7: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold8-431f2a98e-20261108t055310z
- Round 11: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb2-69a91e9ba-20261110t022328z
- Round 13: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb8-f6583590ed-20261110t195418z
- Round 15 (final stack): https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb15-1686cdb39f-20261111t191953z

Changes visible to existing users:
- Removes DBOptions::experimental_allow_wal_partitions_for_testing, its "experimental_allow_wal_partitions_for_testing" options-string key (which no longer parses) and the C API functions rocksdb_options_set/get_experimental_allow_wal_partitions_for_testing. All were added earlier in this stack (D117251769) and never released.
- The --wal_partitions help text of db_bench and db_stress changed.

Test Plan:
M4 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 4974 tests, 0 failed.

M5 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of compaction_service_test, db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_wal_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 7324 tests, 0 failed.

M6 B.1: PASS (debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7340/7340).

Rebased stack (e591f5f): PASS. Debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7559/7559. Full make suite 10540/10540.

Rebased stack (e732049, fbcode/warm 4df7e0a0db7b) final: clang per-diff gates for all 39 diffs; full make suite 10576/10579 at f4c2cc3436 with the 3 round-12 failures fixed at 7fd6043 (transaction_test 3475/3475); clang TSan; crash tests and the two sandcastle repro command lines above. At b19275b: db_write_test under ASAN/UBSAN (clang) 581/581; clang per-diff gates for D121858039 through D123971668 rerun and pass; fbcode/rocks/sandcastle/check-format.sh passes at every diff.
fbcode sandcastle crash tests (blackbox and whitebox; plain, ASAN, TSAN): 6/6 pass on 32fe728cb06b.
Strict status (ASSERT_STATUS_CHECKED=1) suite at f658359: 0 aborts from this stack (27 before the fix).
Rebased stack (facebook/rocksdb eb12834, fbcode/master b1d9881f429e) final: clang per-diff gates for all 39 diffs; full make suite 11192/11192; clang TSan 709/709 once and 2600/2600 at 100x; ASSERT_STATUS_CHECKED with only range_locking_test failing (not touched by this stack); crash tests blackbox and whitebox at wal_partitions 1 and 8 exit 0; `tools/db_crashtest_test.py` 89/89; check-format.sh passes at every diff.

Differential Revision: https://phabricator.intern.facebook.com/D130396596
JustinGaoF pushed a commit to JustinGaoF/rocksdb that referenced this pull request Nov 19, 2026
…n builds

Summary:
The flip of the PartitionWAL stack (GC18 Q1-Q5). DB::Open accepts
wal_partitions > 1 with an indexing partition_wal_usage in release and
debug builds, with no sync point and no opt-in. kNone with N>1 and every
other M1.4 rejection still fail with their exact Status. The
wal_partitions doc and the release notes describe the shipped behaviour
and the rollout order (readers first).

Removes:
- the N>1 gate in DBImpl::ValidateOptions and its debug sync point
  DBImpl::ValidateOptions:AllowWalPartitions;
- the GC13 opt-in experimental_allow_wal_partitions_for_testing
  (D-G18k (i)): the option, its OPTIONS-map entry, Dump line, generated C
  accessors (two "removed" entries are added to tools/c_api_gen/api_compatibility_allowlist.json); db_bench, db_stress and
  test::SetWalPartitions stop setting it;
- every use of the hook in tests and tools, including the hooks that
  tests folded below this commit carry at M4 (exception X14:
  FailedSyncPrepareLeavesNoStaleFence, GC23TimestampedSnapshotsSurviveFlushStress,
  GC19TornFirstRecordInBrandNewNTwoDbModes, CreateBrandNewPartitionedDb,
  GC23FloorOffForLaterGenerationHeads, GC24HistoryFloorScopeOnUpgrade) and
  the original hooks of SyncPrepareAfterSyncCommitSurvivesCrash,
  FU14SnapshotRace and FU14H6TornFirstRecordInBrandNewNTwoDb (GC26 Q5(d)).

Adds db_wal_partitions_open_test (GC18 Q1, with GC20 Q9's edits), GC20
Q9's "with indexing it opens" leg of WalPartitionsValidation (exception
X6), GC23 Q8's wal_partitions doc sentences (exception X6), and the
release notes unreleased_history/new_features/wal_partitions.md,
behavior_changes/partition_wal_sync_visibility.md (GC25) and
behavior_changes/partition_wal_recovery_modes.md (GC26) (exception X19:
they describe behaviour production builds reach only from this commit).

Recorded exception: this commit stays a standalone diff on top of the
stack and is never folded (GC18 round decision, design audit G3-C-2), so it
can be reviewed, landed and reverted alone, and N>1 never becomes legal
partway up the stack.

M5 fold: Absorbs 10 A.1 entries (GC28 1, GC27 3, GC30 2, GC29a 2, GC31 1, GC32 1): the five new release-note files (X19-M5); the post-flip wal_partitions doc lines (GC27, GC30, GC29a); wal_partitions.md. Exceptions: X19-M5. Release notes added here (X19-M5): bug_fixes/partition_wal_recovery_and_visibility_fixes.md, new_features/partition_wal_file_scoped_resume.md, performance_improvements/partition_wal_targeted_gate_sync.md, performance_improvements/partition_wal_write_path_locks.md, performance_improvements/partition_wal_write_pipeline.md. Removes the X14-M5 hook lines: the AllowWalPartitions callbacks D123079329, D123701876, D123928339, D123971668, D127093323 and D127275775 added to their folded N>1 tests.

M6 fold: removes the `DBImpl::ValidateOptions:AllowWalPartitions` hook lines added below the flip to the GC34 Q1 tests (`RunReplayedPrepareIsNotCut`); no other change.

Benchmark (rebased stack, paired and interleaved):

Release `db_bench` built at the rebased stack (fork f4c2cc3436 on facebook/rocksdb e732049; the final 7fd6043 differs only in transaction_test.cc). Workload: `fillrandom`, 3000 ops per thread, 4 KiB values, 64 column families, pipelined write off, auto compactions off, DB on /dev/shm. The latency-injection FileSystem adds a 200 us WAL append latency and a 200 us WAL sync latency (20 us jitter, fixed seed 1001). Profile S caps WAL append and sync bandwidth at 50 MB/s each. Profile S-sync caps only sync bandwidth (50 MB/s). There are three rounds, and each round runs every cell, rotating the cell order. The table reports the median of the three runs (min-max across runs). The ratio is the median of the per-round ratios against N=1 kNone. Host is shared: 1-minute load average 12-67 during the runs (other users). Sync column: `all` = `--sync`, `1-in-20` = `--sync_write_one_in=20`, `none` = no sync.

| Profile | Sync | Cell | ops/s (median of 3) | min-max | vs N=1 kNone | mean write us | p99 write us | WAL appends | WAL syncs |
|---|---|---|---|---|---|---|---|---|---|
| S | all | N=1 kNone | 5425 | 5282-5490 | 1.00x | 11646 | 13984 | 6002 | 6002 |
| S | all | N=1 indexed | 5374 | 4871-5456 | 0.98x | 11716 | 14528 | 6007 | 6005 |
| S | all | N=8 | 20104 | 20098-20516 | 3.71x | 3163 | 6351 | 90202 | 48470 |
| S | all | N=16 | 22746 | 21715-23222 | 4.14x | 2794 | 5075 | 133766 | 80580 |
| S | 1-in-20 | N=1 kNone | 5659 | 5645-5672 | 1.00x | 11283 | 58960 | 6149 | 2042 |
| S | 1-in-20 | N=1 indexed | 5669 | 5624-5680 | 1.00x | 11270 | 60891 | 6027 | 1916 |
| S | 1-in-20 | N=8 | 21635 | 20743-21835 | 3.81x | 2940 | 6587 | 63675 | 20851 |
| S | 1-in-20 | N=16 | 24240 | 23984-24506 | 4.29x | 2620 | 6208 | 105691 | 38739 |
| S | none | N=1 kNone | 10627 | 10435-10702 | 1.00x | 6015 | 6595 | 6005 | 0 |
| S | none | N=1 indexed | 10631 | 10433-10650 | 1.00x | 6012 | 6598 | 6007 | 0 |
| S | none | N=8 | 48068 | 47452-48281 | 4.52x | 1318 | 2788 | 48464 | 0 |
| S | none | N=16 | 63757 | 63551-63974 | 6.00x | 992 | 1881 | 83100 | 0 |
| S-sync | all | N=1 kNone | 9725 | 9722-9781 | 1.00x | 6570 | 9790 | 6003 | 6003 |
| S-sync | all | N=1 indexed | 9776 | 9770-9792 | 1.00x | 6539 | 9621 | 6006 | 6004 |
| S-sync | all | N=8 | 28877 | 27685-29180 | 2.97x | 2208 | 4214 | 88995 | 46361 |
| S-sync | all | N=16 | 27734 | 26727-29899 | 2.85x | 2292 | 4318 | 134123 | 78895 |
| S-sync | 1-in-20 | N=1 kNone | 10263 | 10190-10338 | 1.00x | 6220 | 19308 | 6029 | 2525 |
| S-sync | 1-in-20 | N=1 indexed | 10330 | 10159-10355 | 1.00x | 6180 | 28946 | 6029 | 2329 |
| S-sync | 1-in-20 | N=8 | 29514 | 29500-29519 | 2.88x | 2152 | 5876 | 61844 | 21538 |
| S-sync | 1-in-20 | N=16 | 30808 | 30736-31239 | 3.02x | 2059 | 4387 | 103682 | 39121 |
| S-sync | none | N=1 kNone | 72763 | 72596-74166 | 1.00x | 873 | 1293 | 6013 | 0 |
| S-sync | none | N=1 indexed | 74786 | 72987-75086 | 1.01x | 850 | 1285 | 6016 | 0 |
| S-sync | none | N=8 | 123028 | 120951-124222 | 1.67x | 512 | 862 | 39044 | 0 |
| S-sync | none | N=16 | 133228 | 129421-133491 | 1.80x | 471 | 855 | 71038 | 0 |
| S, 16 threads | all | N=1 kNone | 4724 | 4387-4738 | 1.00x | 3346 | 6482 | 4022 | 4022 |
| S, 16 threads | all | N=1 indexed | 4713 | 4707-4736 | 1.00x | 3334 | 6478 | 3958 | 3956 |
| S, 16 threads | all | N=8 | 8494 | 8464-8529 | 1.80x | 1873 | 2895 | 40476 | 27290 |
| S, 16 threads | all | N=16 | 9294 | 9250-9323 | 1.97x | 1711 | 2876 | 44226 | 34317 |

All 84 runs exited 0. Command per cell:

```
db_bench --benchmarks=fillrandom --threads=64 --num=3000 --value_size=4096 \
  --num_column_families=64 --wal_partitions=<N> --partition_wal_usage=<none|partition_by_column_family> \
  --enable_pipelined_write=false --disable_auto_compactions=1 --statistics --histogram \
  --inject_wal_latency --wal_append_latency_us=200 --wal_sync_latency_us=200 \
  --wal_latency_jitter_us=20 --wal_latency_seed=1001 --seed=1001 \
  --wal_append_bandwidth_mbps=<50|0> --wal_sync_bandwidth_mbps=50 [--sync | --sync_write_one_in=20]
```

N=1 against upstream (default options, no partitioning flags, no latency injection): release `db_bench` of this stack against release `db_bench` of facebook/rocksdb e732049, five rounds, alternating which binary runs first, DB on /dev/shm.

| Workload | upstream e732049 ops/s (median) | min-max | this stack ops/s (median) | min-max | stack/upstream (median of per-round) |
|---|---|---|---|---|---|
| fillrandom, 64 threads x 20000, 64 CFs, 4 KiB values, no sync | 224575 | 219463-232611 | 220572 | 213377-226176 | 0.972x |
| fillrandom, 16 threads x 200000, 1 KiB values, --sync | 532901 | 524086-611361 | 530771 | 525389-541405 | 0.999x |

Per-round stack/upstream ratios: --sync 0.996, 0.999, 1.032, 1.000, 0.860; no sync 0.972, 1.007, 0.948, 0.951, 0.990. 1-minute load average 11-22 during the runs. All 20 runs exited 0. The earlier run of the same comparison on e591f5f measured 0.996x (--sync) and 0.979x (no sync).

Stress (db_stress crash test with the latency-injection FileSystem wired in):

`tools/db_crashtest.py` blackbox and whitebox, 1800 s each, at wal_partitions 1 and 8, on the stack rebased onto facebook/rocksdb eb12834 (fork 286fdab796, debug db_stress; the final stack differs only in clang-format line wrapping and in `tools/db_crashtest.py`/`db_crashtest_test.py`). Pinned: `--disable_wal=0 --partition_wal_usage=partition_by_column_family --enable_blob_direct_write=0 --best_efforts_recovery=0 --two_write_queues=0 --enable_pipelined_write=0 --unordered_write=0 --recycle_log_file_num=0 --track_and_verify_wals=0 --inplace_update_support=0 --use_optimistic_txn=0`, plus `--inject_wal_latency=1 --wal_append_latency_us=50 --wal_sync_latency_us=300 --wal_latency_jitter_us=50 --wal_append_bandwidth_mbps=200 --wal_sync_bandwidth_mbps=100`. Every db_stress command line in the logs was checked for WAL on, latency injection on and the intended wal_partitions; randomized overrides did not disable them.

| Mode | wal_partitions | db_stress command lines | Result |
|---|---|---|---|
| blackbox | 1 | 31 | exit 0 |
| blackbox | 8 | 31 | exit 0 |
| whitebox | 1 | 16 | exit 0 |
| whitebox | 8 | 26 | exit 0 |

The same runs on the previous base (fork f4c2cc3436 on e732049) also exited 0 (31/31/22/12 command lines). The two fbcode sandcastle crash-test command lines that failed on the previous version (ASAN and blackbox, with `read_fault_one_in=1000`) were rerun locally against this stack, three times each for 1200 s: no failure.

fbcode sandcastle crash tests:

The six `rocksdb-contrun.sky` crash-test workflows ran on stack top 32fe728cb06b, scheduled 2026-11-10 05:32 UTC. The final stack differs from it only in test code, one comment and one line break (the ASAN and format fixes below); db_stress is unchanged. All six passed.

| Workflow | Result | Finished (PST, 2026-11-10) |
|---|---|---|
| fbcode_blackbox_crash_test | pass | 00:57 |
| fbcode_asan_blackbox_crash_test | pass | 00:57 |
| fbcode_tsan_blackbox_crash_test | pass | 01:16 |
| fbcode_whitebox_crash_test | pass | 03:37 |
| fbcode_asan_whitebox_crash_test | pass | 03:37 |
| fbcode_tsan_whitebox_crash_test | pass | 03:28 |

Sandcastle jobs: 49539596750420932, 49539596750421833, 40532397491966602, 49539596750421523, 45035997124599077, 22518001256897652 (https://www.internalfb.com/intern/sandcastle/job/<id>/). On the previous submitted version two of these workflows had failed (the sandcastle P1 below); that fix is in this stack.

Comprehensive review (15 rounds, whole 39-diff stack):

Each round ran the comprehensive-diff-review protocol (read-only Opus reviewers; round 1 used four reviewers by area, later rounds one) against the cumulative stack, on facebook/rocksdb d6a7847 for rounds 1-7 and, after the rebase onto e591f5f (the RocksDB subtree of fbcode/warm), on the rebased stack for rounds 8-11, on facebook/rocksdb e732049 (fbcode/warm 4df7e0a0db7b) for rounds 12-13, on 9ce1bfb (fbcode/warm 37d097c1b953) for round 14 and on eb12834 (fbcode/master b1d9881f429e) for round 15. Rounds 14 and 15 reviewed the rebase delta. Rows marked sandcastle, external and crash test are defects found outside the review rounds and fixed the same way. Every P1/P2 was re-checked against the code, reproduced by a new test that fails first, fixed in the diff that introduced the code, and verified by a neuter (reverting the fix makes the test fail). Candidates are the fork's review folds of pwal/m6.

| Round | Candidate | P1/P2 found | Fixed in | Regression test |
|---|---|---|---|---|
| 1 | pwal/m6 69c13fc | 4 P2: CMake missed db/log_merge.cc and log_merge_test; a secondary could not open or catch up beside an indexed primary with async_wal_precreate; a damaged first record in a WAL with an intact head floor and no span made the DB unopenable; commit_bypass_memtable failed after Prepare at N>1 | D120624825 (CMake), D127093323 (async_wal_precreate sanitized off when partition_wal_usage != kNone), D120649665 (HeadBounded counts the WAL's own head floor), D123079329 (bypass falls back to the memtable commit at N>1) | DBSecondaryTest.IndexedPrimaryDisablesAsyncWalPrecreate; DBWalPartitionCoverageTest.DamagedFirstRecordAfterUpgradeToTwoPartitions; TransactionPartitionedWalTest.CommitBypassMemtableCommitsNormally |
| 2 | fold2 2e8c56707a8f | 2 P2: GetSortedWalFiles returned a false Corruption once coupled rotation retired an idle partition's metadata-only WAL that the MANIFEST tracks; GC24HistoryFloorScopeOnUpgrade still pinned the pre-fix outcome | D127093323, D127837663 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWals |
| 3 | fold3 8b6590498 | 1 P2: that fix was keyed to the opener's wal_partitions, so read-only or N=1 openers still got the Corruption. Writing its test exposed a read-only open with WAL tracking off hitting `assert(recovery_ctx != nullptr)` in Recover; fixed too | D127093323 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWalsReadOnly |
| 4 | fold5 c3c369362 | 1 P2: at N=1 indexed, a data-less current WAL got a cached synthetic start sequence 1, so GetUpdatesSince skipped the older WAL holding the requested sequence | D127093323 | DBWalIteratorTest.IndexedDataLessCurrentWalKeepsOlderWal |
| 5 | fold6 6e3ad3889 | None. The per-diff gate then failed WalPartitions8/WritePreparedTransactionTest.{WC_WP_ForwardCompatibility, WP_WC_DBBackwardCompatibility}: listing every metadata-only WAL changed GetSortedWalFiles after a flush; reworked to upstream listing semantics | D127093323 | the two WritePrepared tests, unmodified |
| 6 | fold7 376fac935 | 1 P2: the rework left MANIFEST-tracked metadata-only WALs out of GetSortedWalFiles, so a GetLiveFiles(flush_memtable=false) + GetSortedWalFiles copy failed to open ("Missing WAL with log number"). Now a tracked metadata-only WAL is listed (start sequence 1, not cached) and an untracked one is skipped | D127093323 | DBWritePartitionTest.LiveFilesAndSortedWalFilesCopyOpens |
| 7 | fold8 431f2a98e | None (1 P3, below) | | |
| 8 | rebased 188e02204b43 (onto e591f5f; two reviewers) | None | | |
| sandcastle | previous submitted version | 1 P1 (fbcode crash tests with `read_fault_one_in=1000`): an injected WAL read I/O error during recovery surfaced as `Corruption: WAL index merge: WAL <n> head damaged and unattested` in the merged replay, and the classification pass ignored it | D120624825 (the merger keeps the read's IOError), D121636079/D121674557 (classification returns it), D123928339 (merged replay returns the merger's error before the damage checks) | LogMergeTest.FailedReadKeepsTheReadError; DBWALIndexTest.ClassificationReadIOErrorFailsRecovery; DBWalPartitionCoverageTest.MergeReadIOErrorFailsWithTheReadError |
| 9 | 805ea60 | 2 P3 + 1 gap, fixed: sequential indexed replay replaced the read IOError with a generic one; the merger's error dropped the read's retryable/data-loss/scope attributes | D120415420, D120624825 | DBWALIndexTest.SequentialIndexedReplayReadIOErrorKeepsTheReadError; LogMergeTest.FailedReadKeepsTheReadErrorAttributes |
| external | D119751506 reviewer comment | 1 P2: with manual_wal_flush the burned-index void cover appended to the WAL buffer without wal_write_mutex_, racing an application FlushWAL | D119751506 (takes the mutex as WriteToWAL does), D122412677 (per-partition mutex) | DBWALIndexTest.BurnedWALIndexCoverHoldsWALMutexWithManualFlush |
| crash test | 805ea60 | 1 P2 (debug only): whitebox crash test at N=8 hit the FlushScheduler::Empty consistency assertion when another partition leader dequeued concurrently | D123079329 (Empty reads the head under the debug checking mutex; release builds unchanged) | DBWritePartitionTest.FlushSchedulerEmptyRacesAnotherLeadersDequeue |
| 10 | 12aad1d | 1 P2: statuses on the merged-recovery read-error path left unchecked (ASSERT_STATUS_CHECKED abort) | D120624825, D123551605, D123701876, D123928339, D123971668, D127093323 (holders permitted, ignored reports marked) | the read-error tests above under ASSERT_STATUS_CHECKED |
| 11 | 69a91e9 | None | | |
| fbcode CI | previous submitted version | 1 P2 (build): D120624825 declared two private fields (`last_sequence_index_`, `last_sequence_wal_`) first used in D120649665, so clang failed with -Werror,-Wunused-private-field at D120624825 | D120624825 (the fields move to D120649665; later diffs unchanged) | clang per-diff build gate |
| 12 | f4c2cc3436 (rebased onto e732049) | 1 P2 (tests): upstream's new TransactionTest.InplaceUpdateSupportRequiresWriteCommitted also runs in this stack's WalPartitions8 instantiation, where Open rejects its options; 3 deterministic failures | D127275775 (at wal_partitions > 1 the test asserts NotSupported) | the test itself: 3 failures before, 33/33 after |
| 12 (re-review) | 7fd6043 | None | | |
| fbcode CI | 7fd6043 | 1 P2 (ASAN, test-only): GC31FollowerExitGroup freed its local Env while the fixture's last options still pointed at it, so the next DestroyAndReopen read freed memory (heap-use-after-free in NGreaterThan1FollowerExitHandsFailureToLeader); and the rocks format check flagged a comment over 80 columns and one unjoined condition | D123701876 (the helper resets the fixture's env on exit); D121858039, D123079329, D123551605, D123971668 (clang-format output) | the test under ASAN: heap-use-after-free before, 4/4 and db_write_test 581/581 after; check-format.sh passes on all 39 diffs |
| strict status | b19275b | 1 P2 (ASSERT_STATUS_CHECKED, GitHub CI): 27 aborts from unchecked statuses: a reader report superseded by a more specific recovery error, a per-record pending report on early returns, the gate sync's covered path, a background-error return, an ingestion early return, and three test-side cases. Release behaviour unchanged | D120415420, D120649665, D123476301, D123701876, D123928339, D123971668, D127837663 | the ASSERT_STATUS_CHECKED suite: 27 aborts before, 0 after |
| 13 | f658359 | None | | |
| 14 | m6-rb10 (rebased onto 9ce1bfb) | 1 P2 (tests, from my rebase resolution): upstream's new kSortedHash option config was not skipped at wal_partitions > 1, where Open accepts only the SkipList memtable, so 7 WalPartitions8/ExternalSSTFileTestN tests walking ChangeOptions failed to reopen | D127275775 (kSortedHash joins the N>1 skip list) | the 7 tests: fail before, pass after |
| 15 | 286fdab796 (rebased onto eb12834) | 1 P2 (crash test): upstream meta#15626 moved the inplace_update_support sanitizing ahead of this stack's N>1 overrides, which turned allow_concurrent_memtable_write back on, so about 3% of default crash-test series failed DB::Open. Found while verifying it: the same overrides replaced explicitly passed flags and made `make db_crashtest_tests` fail in about 5 of 6 runs, already on the previous stack (1 more P2) | D126533194 (N>1 steering moved into gen_cmd_params, before command-line flags) | db_crashtest_test.py: 3 new tests, each failing with the old overrides |
| 15 (re-review) | 0d68d5f821 | 2 P2 + 1 P3 in that fix: test_secondary was still drawn per run, so wal_partitions flipped between runs and a secondary could open over partition WALs; an explicit --wal_partitions was not steered; the new test helper did not pin the trie index (about 4% flaky) | D126533194 | test_wal_partitions_stays_fixed_across_runs, test_explicit_wal_partitions_is_steered (each fails under its neuter); suite 89/89 in 40 runs |
| fbcode CI | V1.2 drafts (1686cdb39f) | 1 P2 (stack order, crash test): D126533194 is the first diff whose crash test draws wal_partitions > 1, but the db_stress LockWAL check that accepts GetCurrentWalFile() NotSupported at N>1 lived in this diff, so whitebox runs at D126533194 failed with "GetCurrentWalFile() failed: Not implemented" | D126533194 (the check moves down from this diff; the final tree is unchanged) | local blackbox at wal_partitions=8, lock_wal_one_in=2000: the old D126533194 fails on its 2nd run (192 errors), the new one passes 11/11 |

Final state: all 39 diffs at fork 1686cdb39f on facebook/rocksdb eb12834, each mirrored byte-identically into its fbsource diff on fbcode/master b1d9881f429e (master has since gained one RocksDB commit, c043e8dfa272, touching include/rocksdb/options.h about 180 lines from this stack's hunks). At 286fdab796 (the final stack differs only in clang-format line wrapping and the crash-test Python): per-diff clang gate for all 39 diffs; full make suite 11192/11192; clang TSan once 709/709 and 100x 2600/2600; ASSERT_STATUS_CHECKED suite with no failures from this stack (range_locking_test only, below); crash tests above. At 1686cdb39f: db_write_test 581/581, the gap-filler tests, `tools/db_crashtest_test.py` 89/89, and fbcode/rocks/sandcastle/check-format.sh at every diff. Totals: 1 P1 and 20 P2 fixed.

Open items (P3 or validation gaps, tracked as follow-ups, not fixed here):
- ASSERT_STATUS_CHECKED: range_locking_test fails in that build mode at upstream e732049 too; it is not part of this stack.
- Rebase gap (pre-existing): with recycle_log_file_num > 0, an indexed one-partition DB gets no WAL sequence-gap filler (upstream meta#15581 covers kNone only), so an ingestion gap at a WAL boundary can still stop point-in-time recovery there, as it did for every DB before meta#15581.
- Round 9 F-002 (P3): consumer head checks report a WAL read I/O error as NotSupported.
- Round 11 gap (low confidence, pre-existing): the void re-read during recovery can swallow a transient read IOError.
- TSan with the gcc 11 runtime (libtsan.so.0) reports false "double lock of a mutex" on any std::condition_variable::wait_for mutex, upstream TransactionDB code included, because it does not intercept pthread_cond_clockwait. Use clang TSan.
- Round 7 P3: after an open that writes supersession records without a dummy write (for example a WalFilter stop with avoid_flush_during_recovery=true), partition 0's untracked, data-less current WAL carries the supersession record. GetSortedWalFiles skips it, so a GetLiveFiles + GetSortedWalFiles copy could fail with "two live records share index". Checkpoint and BackupEngine are unaffected. Inferred from code, not reproduced.
- Round 2 P3: WriteRecoverableState at N>1 can stamp the cached recoverable state inside an open fence during an auto-resumed retryable WAL error.
- Round 1 P3s: the checkpoint/backup LockWAL race tests can stop on an ASSERT before joining their threads; GC31FollowerExitGroup orders writers with sleeps; standalone db_stress at N>1 trips on the default get_current_wal_file_one_in; checkpoint/backup at N>1 wait out a write stop.
- Gaps: an indexed DB with wal_compression still caches start sequence 1 for a data-less WAL (as upstream does for compression-only WALs); HeadFloor() for a member with no surviving data is the last progress bound read (no production-reachable loss found).

Reports (MetaMate):
- Round 1: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-69c13fcb72e2-20261107t093444z
- Round 2: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold2-2e8c56707a8f-20261107t175411z
- Round 3: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold3-8b6590498-20261107t185930z
- Round 4: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold5-c3c369362-20261107t192653z
- Round 5: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold6-6e3ad3889-20261107t193256z
- Round 6: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold7-376fac935-20261108t054421z
- Round 7: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold8-431f2a98e-20261108t055310z
- Round 11: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb2-69a91e9ba-20261110t022328z
- Round 13: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb8-f6583590ed-20261110t195418z
- Round 15 (final stack): https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb15-1686cdb39f-20261111t191953z

Changes visible to existing users:
- Removes DBOptions::experimental_allow_wal_partitions_for_testing, its "experimental_allow_wal_partitions_for_testing" options-string key (which no longer parses) and the C API functions rocksdb_options_set/get_experimental_allow_wal_partitions_for_testing. All were added earlier in this stack (D117251769) and never released.
- The --wal_partitions help text of db_bench and db_stress changed.

Test Plan:
M4 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 4974 tests, 0 failed.

M5 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of compaction_service_test, db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_wal_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 7324 tests, 0 failed.

M6 B.1: PASS (debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7340/7340).

Rebased stack (e591f5f): PASS. Debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7559/7559. Full make suite 10540/10540.

Rebased stack (e732049, fbcode/warm 4df7e0a0db7b) final: clang per-diff gates for all 39 diffs; full make suite 10576/10579 at f4c2cc3436 with the 3 round-12 failures fixed at 7fd6043 (transaction_test 3475/3475); clang TSan; crash tests and the two sandcastle repro command lines above. At b19275b: db_write_test under ASAN/UBSAN (clang) 581/581; clang per-diff gates for D121858039 through D123971668 rerun and pass; fbcode/rocks/sandcastle/check-format.sh passes at every diff.
fbcode sandcastle crash tests (blackbox and whitebox; plain, ASAN, TSAN): 6/6 pass on 32fe728cb06b.
Strict status (ASSERT_STATUS_CHECKED=1) suite at f658359: 0 aborts from this stack (27 before the fix).
Rebased stack (facebook/rocksdb eb12834, fbcode/master b1d9881f429e) final: clang per-diff gates for all 39 diffs; full make suite 11192/11192; clang TSan 709/709 once and 2600/2600 at 100x; ASSERT_STATUS_CHECKED with only range_locking_test failing (not touched by this stack); crash tests blackbox and whitebox at wal_partitions 1 and 8 exit 0; `tools/db_crashtest_test.py` 89/89; check-format.sh passes at every diff.

Differential Revision: https://phabricator.intern.facebook.com/D130396596
JustinGaoF pushed a commit to JustinGaoF/rocksdb that referenced this pull request Nov 19, 2026
…n builds

Summary:
The flip of the PartitionWAL stack (GC18 Q1-Q5). DB::Open accepts
wal_partitions > 1 with an indexing partition_wal_usage in release and
debug builds, with no sync point and no opt-in. kNone with N>1 and every
other M1.4 rejection still fail with their exact Status. The
wal_partitions doc and the release notes describe the shipped behaviour
and the rollout order (readers first).

Removes:
- the N>1 gate in DBImpl::ValidateOptions and its debug sync point
  DBImpl::ValidateOptions:AllowWalPartitions;
- the GC13 opt-in experimental_allow_wal_partitions_for_testing
  (D-G18k (i)): the option, its OPTIONS-map entry, Dump line, generated C
  accessors (two "removed" entries are added to tools/c_api_gen/api_compatibility_allowlist.json); db_bench, db_stress and
  test::SetWalPartitions stop setting it;
- every use of the hook in tests and tools, including the hooks that
  tests folded below this commit carry at M4 (exception X14:
  FailedSyncPrepareLeavesNoStaleFence, GC23TimestampedSnapshotsSurviveFlushStress,
  GC19TornFirstRecordInBrandNewNTwoDbModes, CreateBrandNewPartitionedDb,
  GC23FloorOffForLaterGenerationHeads, GC24HistoryFloorScopeOnUpgrade) and
  the original hooks of SyncPrepareAfterSyncCommitSurvivesCrash,
  FU14SnapshotRace and FU14H6TornFirstRecordInBrandNewNTwoDb (GC26 Q5(d)).

Adds db_wal_partitions_open_test (GC18 Q1, with GC20 Q9's edits), GC20
Q9's "with indexing it opens" leg of WalPartitionsValidation (exception
X6), GC23 Q8's wal_partitions doc sentences (exception X6), and the
release notes unreleased_history/new_features/wal_partitions.md,
behavior_changes/partition_wal_sync_visibility.md (GC25) and
behavior_changes/partition_wal_recovery_modes.md (GC26) (exception X19:
they describe behaviour production builds reach only from this commit).

Recorded exception: this commit stays a standalone diff on top of the
stack and is never folded (GC18 round decision, design audit G3-C-2), so it
can be reviewed, landed and reverted alone, and N>1 never becomes legal
partway up the stack.

M5 fold: Absorbs 10 A.1 entries (GC28 1, GC27 3, GC30 2, GC29a 2, GC31 1, GC32 1): the five new release-note files (X19-M5); the post-flip wal_partitions doc lines (GC27, GC30, GC29a); wal_partitions.md. Exceptions: X19-M5. Release notes added here (X19-M5): bug_fixes/partition_wal_recovery_and_visibility_fixes.md, new_features/partition_wal_file_scoped_resume.md, performance_improvements/partition_wal_targeted_gate_sync.md, performance_improvements/partition_wal_write_path_locks.md, performance_improvements/partition_wal_write_pipeline.md. Removes the X14-M5 hook lines: the AllowWalPartitions callbacks D123079329, D123701876, D123928339, D123971668, D127093323 and D127275775 added to their folded N>1 tests.

M6 fold: removes the `DBImpl::ValidateOptions:AllowWalPartitions` hook lines added below the flip to the GC34 Q1 tests (`RunReplayedPrepareIsNotCut`); no other change.

Benchmark (rebased stack, paired and interleaved):

Release `db_bench` built at the rebased stack (fork f4c2cc3436 on facebook/rocksdb e732049; the final 7fd6043 differs only in transaction_test.cc). Workload: `fillrandom`, 3000 ops per thread, 4 KiB values, 64 column families, pipelined write off, auto compactions off, DB on /dev/shm. The latency-injection FileSystem adds a 200 us WAL append latency and a 200 us WAL sync latency (20 us jitter, fixed seed 1001). Profile S caps WAL append and sync bandwidth at 50 MB/s each. Profile S-sync caps only sync bandwidth (50 MB/s). There are three rounds, and each round runs every cell, rotating the cell order. The table reports the median of the three runs (min-max across runs). The ratio is the median of the per-round ratios against N=1 kNone. Host is shared: 1-minute load average 12-67 during the runs (other users). Sync column: `all` = `--sync`, `1-in-20` = `--sync_write_one_in=20`, `none` = no sync.

| Profile | Sync | Cell | ops/s (median of 3) | min-max | vs N=1 kNone | mean write us | p99 write us | WAL appends | WAL syncs |
|---|---|---|---|---|---|---|---|---|---|
| S | all | N=1 kNone | 5425 | 5282-5490 | 1.00x | 11646 | 13984 | 6002 | 6002 |
| S | all | N=1 indexed | 5374 | 4871-5456 | 0.98x | 11716 | 14528 | 6007 | 6005 |
| S | all | N=8 | 20104 | 20098-20516 | 3.71x | 3163 | 6351 | 90202 | 48470 |
| S | all | N=16 | 22746 | 21715-23222 | 4.14x | 2794 | 5075 | 133766 | 80580 |
| S | 1-in-20 | N=1 kNone | 5659 | 5645-5672 | 1.00x | 11283 | 58960 | 6149 | 2042 |
| S | 1-in-20 | N=1 indexed | 5669 | 5624-5680 | 1.00x | 11270 | 60891 | 6027 | 1916 |
| S | 1-in-20 | N=8 | 21635 | 20743-21835 | 3.81x | 2940 | 6587 | 63675 | 20851 |
| S | 1-in-20 | N=16 | 24240 | 23984-24506 | 4.29x | 2620 | 6208 | 105691 | 38739 |
| S | none | N=1 kNone | 10627 | 10435-10702 | 1.00x | 6015 | 6595 | 6005 | 0 |
| S | none | N=1 indexed | 10631 | 10433-10650 | 1.00x | 6012 | 6598 | 6007 | 0 |
| S | none | N=8 | 48068 | 47452-48281 | 4.52x | 1318 | 2788 | 48464 | 0 |
| S | none | N=16 | 63757 | 63551-63974 | 6.00x | 992 | 1881 | 83100 | 0 |
| S-sync | all | N=1 kNone | 9725 | 9722-9781 | 1.00x | 6570 | 9790 | 6003 | 6003 |
| S-sync | all | N=1 indexed | 9776 | 9770-9792 | 1.00x | 6539 | 9621 | 6006 | 6004 |
| S-sync | all | N=8 | 28877 | 27685-29180 | 2.97x | 2208 | 4214 | 88995 | 46361 |
| S-sync | all | N=16 | 27734 | 26727-29899 | 2.85x | 2292 | 4318 | 134123 | 78895 |
| S-sync | 1-in-20 | N=1 kNone | 10263 | 10190-10338 | 1.00x | 6220 | 19308 | 6029 | 2525 |
| S-sync | 1-in-20 | N=1 indexed | 10330 | 10159-10355 | 1.00x | 6180 | 28946 | 6029 | 2329 |
| S-sync | 1-in-20 | N=8 | 29514 | 29500-29519 | 2.88x | 2152 | 5876 | 61844 | 21538 |
| S-sync | 1-in-20 | N=16 | 30808 | 30736-31239 | 3.02x | 2059 | 4387 | 103682 | 39121 |
| S-sync | none | N=1 kNone | 72763 | 72596-74166 | 1.00x | 873 | 1293 | 6013 | 0 |
| S-sync | none | N=1 indexed | 74786 | 72987-75086 | 1.01x | 850 | 1285 | 6016 | 0 |
| S-sync | none | N=8 | 123028 | 120951-124222 | 1.67x | 512 | 862 | 39044 | 0 |
| S-sync | none | N=16 | 133228 | 129421-133491 | 1.80x | 471 | 855 | 71038 | 0 |
| S, 16 threads | all | N=1 kNone | 4724 | 4387-4738 | 1.00x | 3346 | 6482 | 4022 | 4022 |
| S, 16 threads | all | N=1 indexed | 4713 | 4707-4736 | 1.00x | 3334 | 6478 | 3958 | 3956 |
| S, 16 threads | all | N=8 | 8494 | 8464-8529 | 1.80x | 1873 | 2895 | 40476 | 27290 |
| S, 16 threads | all | N=16 | 9294 | 9250-9323 | 1.97x | 1711 | 2876 | 44226 | 34317 |

All 84 runs exited 0. Command per cell:

```
db_bench --benchmarks=fillrandom --threads=64 --num=3000 --value_size=4096 \
  --num_column_families=64 --wal_partitions=<N> --partition_wal_usage=<none|partition_by_column_family> \
  --enable_pipelined_write=false --disable_auto_compactions=1 --statistics --histogram \
  --inject_wal_latency --wal_append_latency_us=200 --wal_sync_latency_us=200 \
  --wal_latency_jitter_us=20 --wal_latency_seed=1001 --seed=1001 \
  --wal_append_bandwidth_mbps=<50|0> --wal_sync_bandwidth_mbps=50 [--sync | --sync_write_one_in=20]
```

N=1 against upstream (default options, no partitioning flags, no latency injection): release `db_bench` of this stack against release `db_bench` of facebook/rocksdb e732049, five rounds, alternating which binary runs first, DB on /dev/shm.

| Workload | upstream e732049 ops/s (median) | min-max | this stack ops/s (median) | min-max | stack/upstream (median of per-round) |
|---|---|---|---|---|---|
| fillrandom, 64 threads x 20000, 64 CFs, 4 KiB values, no sync | 224575 | 219463-232611 | 220572 | 213377-226176 | 0.972x |
| fillrandom, 16 threads x 200000, 1 KiB values, --sync | 532901 | 524086-611361 | 530771 | 525389-541405 | 0.999x |

Per-round stack/upstream ratios: --sync 0.996, 0.999, 1.032, 1.000, 0.860; no sync 0.972, 1.007, 0.948, 0.951, 0.990. 1-minute load average 11-22 during the runs. All 20 runs exited 0. The earlier run of the same comparison on e591f5f measured 0.996x (--sync) and 0.979x (no sync).

Stress (db_stress crash test with the latency-injection FileSystem wired in):

`tools/db_crashtest.py` blackbox and whitebox, 1800 s each, at wal_partitions 1 and 8, on the stack rebased onto facebook/rocksdb eb12834 (fork 286fdab796, debug db_stress; the final stack differs only in clang-format line wrapping and in `tools/db_crashtest.py`/`db_crashtest_test.py`). Pinned: `--disable_wal=0 --partition_wal_usage=partition_by_column_family --enable_blob_direct_write=0 --best_efforts_recovery=0 --two_write_queues=0 --enable_pipelined_write=0 --unordered_write=0 --recycle_log_file_num=0 --track_and_verify_wals=0 --inplace_update_support=0 --use_optimistic_txn=0`, plus `--inject_wal_latency=1 --wal_append_latency_us=50 --wal_sync_latency_us=300 --wal_latency_jitter_us=50 --wal_append_bandwidth_mbps=200 --wal_sync_bandwidth_mbps=100`. Every db_stress command line in the logs was checked for WAL on, latency injection on and the intended wal_partitions; randomized overrides did not disable them.

| Mode | wal_partitions | db_stress command lines | Result |
|---|---|---|---|
| blackbox | 1 | 31 | exit 0 |
| blackbox | 8 | 31 | exit 0 |
| whitebox | 1 | 16 | exit 0 |
| whitebox | 8 | 26 | exit 0 |

The same runs on the previous base (fork f4c2cc3436 on e732049) also exited 0 (31/31/22/12 command lines). The two fbcode sandcastle crash-test command lines that failed on the previous version (ASAN and blackbox, with `read_fault_one_in=1000`) were rerun locally against this stack, three times each for 1200 s: no failure.

fbcode sandcastle crash tests:

The six `rocksdb-contrun.sky` crash-test workflows ran on stack top 32fe728cb06b, scheduled 2026-11-10 05:32 UTC. The final stack differs from it only in test code, one comment and one line break (the ASAN and format fixes below); db_stress is unchanged. All six passed.

| Workflow | Result | Finished (PST, 2026-11-10) |
|---|---|---|
| fbcode_blackbox_crash_test | pass | 00:57 |
| fbcode_asan_blackbox_crash_test | pass | 00:57 |
| fbcode_tsan_blackbox_crash_test | pass | 01:16 |
| fbcode_whitebox_crash_test | pass | 03:37 |
| fbcode_asan_whitebox_crash_test | pass | 03:37 |
| fbcode_tsan_whitebox_crash_test | pass | 03:28 |

Sandcastle jobs: 49539596750420932, 49539596750421833, 40532397491966602, 49539596750421523, 45035997124599077, 22518001256897652 (https://www.internalfb.com/intern/sandcastle/job/<id>/). On the previous submitted version two of these workflows had failed (the sandcastle P1 below); that fix is in this stack.

Comprehensive review (15 rounds, whole 39-diff stack):

Each round ran the comprehensive-diff-review protocol (read-only Opus reviewers; round 1 used four reviewers by area, later rounds one) against the cumulative stack, on facebook/rocksdb d6a7847 for rounds 1-7 and, after the rebase onto e591f5f (the RocksDB subtree of fbcode/warm), on the rebased stack for rounds 8-11, on facebook/rocksdb e732049 (fbcode/warm 4df7e0a0db7b) for rounds 12-13, on 9ce1bfb (fbcode/warm 37d097c1b953) for round 14 and on eb12834 (fbcode/master b1d9881f429e) for round 15. Rounds 14 and 15 reviewed the rebase delta. Rows marked sandcastle, external and crash test are defects found outside the review rounds and fixed the same way. Every P1/P2 was re-checked against the code, reproduced by a new test that fails first, fixed in the diff that introduced the code, and verified by a neuter (reverting the fix makes the test fail). Candidates are the fork's review folds of pwal/m6.

| Round | Candidate | P1/P2 found | Fixed in | Regression test |
|---|---|---|---|---|
| 1 | pwal/m6 69c13fc | 4 P2: CMake missed db/log_merge.cc and log_merge_test; a secondary could not open or catch up beside an indexed primary with async_wal_precreate; a damaged first record in a WAL with an intact head floor and no span made the DB unopenable; commit_bypass_memtable failed after Prepare at N>1 | D120624825 (CMake), D127093323 (async_wal_precreate sanitized off when partition_wal_usage != kNone), D120649665 (HeadBounded counts the WAL's own head floor), D123079329 (bypass falls back to the memtable commit at N>1) | DBSecondaryTest.IndexedPrimaryDisablesAsyncWalPrecreate; DBWalPartitionCoverageTest.DamagedFirstRecordAfterUpgradeToTwoPartitions; TransactionPartitionedWalTest.CommitBypassMemtableCommitsNormally |
| 2 | fold2 2e8c56707a8f | 2 P2: GetSortedWalFiles returned a false Corruption once coupled rotation retired an idle partition's metadata-only WAL that the MANIFEST tracks; GC24HistoryFloorScopeOnUpgrade still pinned the pre-fix outcome | D127093323, D127837663 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWals |
| 3 | fold3 8b6590498 | 1 P2: that fix was keyed to the opener's wal_partitions, so read-only or N=1 openers still got the Corruption. Writing its test exposed a read-only open with WAL tracking off hitting `assert(recovery_ctx != nullptr)` in Recover; fixed too | D127093323 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWalsReadOnly |
| 4 | fold5 c3c369362 | 1 P2: at N=1 indexed, a data-less current WAL got a cached synthetic start sequence 1, so GetUpdatesSince skipped the older WAL holding the requested sequence | D127093323 | DBWalIteratorTest.IndexedDataLessCurrentWalKeepsOlderWal |
| 5 | fold6 6e3ad3889 | None. The per-diff gate then failed WalPartitions8/WritePreparedTransactionTest.{WC_WP_ForwardCompatibility, WP_WC_DBBackwardCompatibility}: listing every metadata-only WAL changed GetSortedWalFiles after a flush; reworked to upstream listing semantics | D127093323 | the two WritePrepared tests, unmodified |
| 6 | fold7 376fac935 | 1 P2: the rework left MANIFEST-tracked metadata-only WALs out of GetSortedWalFiles, so a GetLiveFiles(flush_memtable=false) + GetSortedWalFiles copy failed to open ("Missing WAL with log number"). Now a tracked metadata-only WAL is listed (start sequence 1, not cached) and an untracked one is skipped | D127093323 | DBWritePartitionTest.LiveFilesAndSortedWalFilesCopyOpens |
| 7 | fold8 431f2a98e | None (1 P3, below) | | |
| 8 | rebased 188e02204b43 (onto e591f5f; two reviewers) | None | | |
| sandcastle | previous submitted version | 1 P1 (fbcode crash tests with `read_fault_one_in=1000`): an injected WAL read I/O error during recovery surfaced as `Corruption: WAL index merge: WAL <n> head damaged and unattested` in the merged replay, and the classification pass ignored it | D120624825 (the merger keeps the read's IOError), D121636079/D121674557 (classification returns it), D123928339 (merged replay returns the merger's error before the damage checks) | LogMergeTest.FailedReadKeepsTheReadError; DBWALIndexTest.ClassificationReadIOErrorFailsRecovery; DBWalPartitionCoverageTest.MergeReadIOErrorFailsWithTheReadError |
| 9 | 805ea60 | 2 P3 + 1 gap, fixed: sequential indexed replay replaced the read IOError with a generic one; the merger's error dropped the read's retryable/data-loss/scope attributes | D120415420, D120624825 | DBWALIndexTest.SequentialIndexedReplayReadIOErrorKeepsTheReadError; LogMergeTest.FailedReadKeepsTheReadErrorAttributes |
| external | D119751506 reviewer comment | 1 P2: with manual_wal_flush the burned-index void cover appended to the WAL buffer without wal_write_mutex_, racing an application FlushWAL | D119751506 (takes the mutex as WriteToWAL does), D122412677 (per-partition mutex) | DBWALIndexTest.BurnedWALIndexCoverHoldsWALMutexWithManualFlush |
| crash test | 805ea60 | 1 P2 (debug only): whitebox crash test at N=8 hit the FlushScheduler::Empty consistency assertion when another partition leader dequeued concurrently | D123079329 (Empty reads the head under the debug checking mutex; release builds unchanged) | DBWritePartitionTest.FlushSchedulerEmptyRacesAnotherLeadersDequeue |
| 10 | 12aad1d | 1 P2: statuses on the merged-recovery read-error path left unchecked (ASSERT_STATUS_CHECKED abort) | D120624825, D123551605, D123701876, D123928339, D123971668, D127093323 (holders permitted, ignored reports marked) | the read-error tests above under ASSERT_STATUS_CHECKED |
| 11 | 69a91e9 | None | | |
| fbcode CI | previous submitted version | 1 P2 (build): D120624825 declared two private fields (`last_sequence_index_`, `last_sequence_wal_`) first used in D120649665, so clang failed with -Werror,-Wunused-private-field at D120624825 | D120624825 (the fields move to D120649665; later diffs unchanged) | clang per-diff build gate |
| 12 | f4c2cc3436 (rebased onto e732049) | 1 P2 (tests): upstream's new TransactionTest.InplaceUpdateSupportRequiresWriteCommitted also runs in this stack's WalPartitions8 instantiation, where Open rejects its options; 3 deterministic failures | D127275775 (at wal_partitions > 1 the test asserts NotSupported) | the test itself: 3 failures before, 33/33 after |
| 12 (re-review) | 7fd6043 | None | | |
| fbcode CI | 7fd6043 | 1 P2 (ASAN, test-only): GC31FollowerExitGroup freed its local Env while the fixture's last options still pointed at it, so the next DestroyAndReopen read freed memory (heap-use-after-free in NGreaterThan1FollowerExitHandsFailureToLeader); and the rocks format check flagged a comment over 80 columns and one unjoined condition | D123701876 (the helper resets the fixture's env on exit); D121858039, D123079329, D123551605, D123971668 (clang-format output) | the test under ASAN: heap-use-after-free before, 4/4 and db_write_test 581/581 after; check-format.sh passes on all 39 diffs |
| strict status | b19275b | 1 P2 (ASSERT_STATUS_CHECKED, GitHub CI): 27 aborts from unchecked statuses: a reader report superseded by a more specific recovery error, a per-record pending report on early returns, the gate sync's covered path, a background-error return, an ingestion early return, and three test-side cases. Release behaviour unchanged | D120415420, D120649665, D123476301, D123701876, D123928339, D123971668, D127837663 | the ASSERT_STATUS_CHECKED suite: 27 aborts before, 0 after |
| 13 | f658359 | None | | |
| 14 | m6-rb10 (rebased onto 9ce1bfb) | 1 P2 (tests, from my rebase resolution): upstream's new kSortedHash option config was not skipped at wal_partitions > 1, where Open accepts only the SkipList memtable, so 7 WalPartitions8/ExternalSSTFileTestN tests walking ChangeOptions failed to reopen | D127275775 (kSortedHash joins the N>1 skip list) | the 7 tests: fail before, pass after |
| 15 | 286fdab796 (rebased onto eb12834) | 1 P2 (crash test): upstream meta#15626 moved the inplace_update_support sanitizing ahead of this stack's N>1 overrides, which turned allow_concurrent_memtable_write back on, so about 3% of default crash-test series failed DB::Open. Found while verifying it: the same overrides replaced explicitly passed flags and made `make db_crashtest_tests` fail in about 5 of 6 runs, already on the previous stack (1 more P2) | D126533194 (N>1 steering moved into gen_cmd_params, before command-line flags) | db_crashtest_test.py: 3 new tests, each failing with the old overrides |
| 15 (re-review) | 0d68d5f821 | 2 P2 + 1 P3 in that fix: test_secondary was still drawn per run, so wal_partitions flipped between runs and a secondary could open over partition WALs; an explicit --wal_partitions was not steered; the new test helper did not pin the trie index (about 4% flaky) | D126533194 | test_wal_partitions_stays_fixed_across_runs, test_explicit_wal_partitions_is_steered (each fails under its neuter); suite 89/89 in 40 runs |
| fbcode CI | V1.2 drafts (1686cdb39f) | 1 P2 (stack order, crash test): D126533194 is the first diff whose crash test draws wal_partitions > 1, but the db_stress LockWAL check that accepts GetCurrentWalFile() NotSupported at N>1 lived in this diff, so whitebox runs at D126533194 failed with "GetCurrentWalFile() failed: Not implemented" | D126533194 (the check moves down from this diff; the final tree is unchanged) | local blackbox at wal_partitions=8, lock_wal_one_in=2000: the old D126533194 fails on its 2nd run (192 errors), the new one passes 11/11 |

Final state: all 39 diffs at fork 1686cdb39f on facebook/rocksdb eb12834, each mirrored byte-identically into its fbsource diff on fbcode/master b1d9881f429e (master has since gained one RocksDB commit, c043e8dfa272, touching include/rocksdb/options.h about 180 lines from this stack's hunks). At 286fdab796 (the final stack differs only in clang-format line wrapping and the crash-test Python): per-diff clang gate for all 39 diffs; full make suite 11192/11192; clang TSan once 709/709 and 100x 2600/2600; ASSERT_STATUS_CHECKED suite with no failures from this stack (range_locking_test only, below); crash tests above. At 1686cdb39f: db_write_test 581/581, the gap-filler tests, `tools/db_crashtest_test.py` 89/89, and fbcode/rocks/sandcastle/check-format.sh at every diff. Totals: 1 P1 and 20 P2 fixed.

Open items (P3 or validation gaps, tracked as follow-ups, not fixed here):
- ASSERT_STATUS_CHECKED: range_locking_test fails in that build mode at upstream e732049 too; it is not part of this stack.
- Rebase gap (pre-existing): with recycle_log_file_num > 0, an indexed one-partition DB gets no WAL sequence-gap filler (upstream meta#15581 covers kNone only), so an ingestion gap at a WAL boundary can still stop point-in-time recovery there, as it did for every DB before meta#15581.
- Round 9 F-002 (P3): consumer head checks report a WAL read I/O error as NotSupported.
- Round 11 gap (low confidence, pre-existing): the void re-read during recovery can swallow a transient read IOError.
- TSan with the gcc 11 runtime (libtsan.so.0) reports false "double lock of a mutex" on any std::condition_variable::wait_for mutex, upstream TransactionDB code included, because it does not intercept pthread_cond_clockwait. Use clang TSan.
- Round 7 P3: after an open that writes supersession records without a dummy write (for example a WalFilter stop with avoid_flush_during_recovery=true), partition 0's untracked, data-less current WAL carries the supersession record. GetSortedWalFiles skips it, so a GetLiveFiles + GetSortedWalFiles copy could fail with "two live records share index". Checkpoint and BackupEngine are unaffected. Inferred from code, not reproduced.
- Round 2 P3: WriteRecoverableState at N>1 can stamp the cached recoverable state inside an open fence during an auto-resumed retryable WAL error.
- Round 1 P3s: the checkpoint/backup LockWAL race tests can stop on an ASSERT before joining their threads; GC31FollowerExitGroup orders writers with sleeps; standalone db_stress at N>1 trips on the default get_current_wal_file_one_in; checkpoint/backup at N>1 wait out a write stop.
- Gaps: an indexed DB with wal_compression still caches start sequence 1 for a data-less WAL (as upstream does for compression-only WALs); HeadFloor() for a member with no surviving data is the last progress bound read (no production-reachable loss found).

Reports (MetaMate):
- Round 1: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-69c13fcb72e2-20261107t093444z
- Round 2: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold2-2e8c56707a8f-20261107t175411z
- Round 3: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold3-8b6590498-20261107t185930z
- Round 4: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold5-c3c369362-20261107t192653z
- Round 5: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold6-6e3ad3889-20261107t193256z
- Round 6: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold7-376fac935-20261108t054421z
- Round 7: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold8-431f2a98e-20261108t055310z
- Round 11: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb2-69a91e9ba-20261110t022328z
- Round 13: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb8-f6583590ed-20261110t195418z
- Round 15 (final stack): https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb15-1686cdb39f-20261111t191953z

Changes visible to existing users:
- Removes DBOptions::experimental_allow_wal_partitions_for_testing, its "experimental_allow_wal_partitions_for_testing" options-string key (which no longer parses) and the C API functions rocksdb_options_set/get_experimental_allow_wal_partitions_for_testing. All were added earlier in this stack (D117251769) and never released.
- The --wal_partitions help text of db_bench and db_stress changed.

Test Plan:
M4 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 4974 tests, 0 failed.

M5 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of compaction_service_test, db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_wal_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 7324 tests, 0 failed.

M6 B.1: PASS (debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7340/7340).

Rebased stack (e591f5f): PASS. Debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7559/7559. Full make suite 10540/10540.

Rebased stack (e732049, fbcode/warm 4df7e0a0db7b) final: clang per-diff gates for all 39 diffs; full make suite 10576/10579 at f4c2cc3436 with the 3 round-12 failures fixed at 7fd6043 (transaction_test 3475/3475); clang TSan; crash tests and the two sandcastle repro command lines above. At b19275b: db_write_test under ASAN/UBSAN (clang) 581/581; clang per-diff gates for D121858039 through D123971668 rerun and pass; fbcode/rocks/sandcastle/check-format.sh passes at every diff.
fbcode sandcastle crash tests (blackbox and whitebox; plain, ASAN, TSAN): 6/6 pass on 32fe728cb06b.
Strict status (ASSERT_STATUS_CHECKED=1) suite at f658359: 0 aborts from this stack (27 before the fix).
Rebased stack (facebook/rocksdb eb12834, fbcode/master b1d9881f429e) final: clang per-diff gates for all 39 diffs; full make suite 11192/11192; clang TSan 709/709 once and 2600/2600 at 100x; ASSERT_STATUS_CHECKED with only range_locking_test failing (not touched by this stack); crash tests blackbox and whitebox at wal_partitions 1 and 8 exit 0; `tools/db_crashtest_test.py` 89/89; check-format.sh passes at every diff.

Differential Revision: https://phabricator.intern.facebook.com/D130396596
JustinGaoF pushed a commit to JustinGaoF/rocksdb that referenced this pull request Nov 19, 2026
…n builds

Summary:
The flip of the PartitionWAL stack (GC18 Q1-Q5). DB::Open accepts
wal_partitions > 1 with an indexing partition_wal_usage in release and
debug builds, with no sync point and no opt-in. kNone with N>1 and every
other M1.4 rejection still fail with their exact Status. The
wal_partitions doc and the release notes describe the shipped behaviour
and the rollout order (readers first).

Removes:
- the N>1 gate in DBImpl::ValidateOptions and its debug sync point
  DBImpl::ValidateOptions:AllowWalPartitions;
- the GC13 opt-in experimental_allow_wal_partitions_for_testing
  (D-G18k (i)): the option, its OPTIONS-map entry, Dump line, generated C
  accessors (two "removed" entries are added to tools/c_api_gen/api_compatibility_allowlist.json); db_bench, db_stress and
  test::SetWalPartitions stop setting it;
- every use of the hook in tests and tools, including the hooks that
  tests folded below this commit carry at M4 (exception X14:
  FailedSyncPrepareLeavesNoStaleFence, GC23TimestampedSnapshotsSurviveFlushStress,
  GC19TornFirstRecordInBrandNewNTwoDbModes, CreateBrandNewPartitionedDb,
  GC23FloorOffForLaterGenerationHeads, GC24HistoryFloorScopeOnUpgrade) and
  the original hooks of SyncPrepareAfterSyncCommitSurvivesCrash,
  FU14SnapshotRace and FU14H6TornFirstRecordInBrandNewNTwoDb (GC26 Q5(d)).

Adds db_wal_partitions_open_test (GC18 Q1, with GC20 Q9's edits), GC20
Q9's "with indexing it opens" leg of WalPartitionsValidation (exception
X6), GC23 Q8's wal_partitions doc sentences (exception X6), and the
release notes unreleased_history/new_features/wal_partitions.md,
behavior_changes/partition_wal_sync_visibility.md (GC25) and
behavior_changes/partition_wal_recovery_modes.md (GC26) (exception X19:
they describe behaviour production builds reach only from this commit).

Recorded exception: this commit stays a standalone diff on top of the
stack and is never folded (GC18 round decision, design audit G3-C-2), so it
can be reviewed, landed and reverted alone, and N>1 never becomes legal
partway up the stack.

M5 fold: Absorbs 10 A.1 entries (GC28 1, GC27 3, GC30 2, GC29a 2, GC31 1, GC32 1): the five new release-note files (X19-M5); the post-flip wal_partitions doc lines (GC27, GC30, GC29a); wal_partitions.md. Exceptions: X19-M5. Release notes added here (X19-M5): bug_fixes/partition_wal_recovery_and_visibility_fixes.md, new_features/partition_wal_file_scoped_resume.md, performance_improvements/partition_wal_targeted_gate_sync.md, performance_improvements/partition_wal_write_path_locks.md, performance_improvements/partition_wal_write_pipeline.md. Removes the X14-M5 hook lines: the AllowWalPartitions callbacks D123079329, D123701876, D123928339, D123971668, D127093323 and D127275775 added to their folded N>1 tests.

M6 fold: removes the `DBImpl::ValidateOptions:AllowWalPartitions` hook lines added below the flip to the GC34 Q1 tests (`RunReplayedPrepareIsNotCut`); no other change.

Benchmark (rebased stack, paired and interleaved):

Release `db_bench` built at the rebased stack (fork f4c2cc3436 on facebook/rocksdb e732049; the final 7fd6043 differs only in transaction_test.cc). Workload: `fillrandom`, 3000 ops per thread, 4 KiB values, 64 column families, pipelined write off, auto compactions off, DB on /dev/shm. The latency-injection FileSystem adds a 200 us WAL append latency and a 200 us WAL sync latency (20 us jitter, fixed seed 1001). Profile S caps WAL append and sync bandwidth at 50 MB/s each. Profile S-sync caps only sync bandwidth (50 MB/s). There are three rounds, and each round runs every cell, rotating the cell order. The table reports the median of the three runs (min-max across runs). The ratio is the median of the per-round ratios against N=1 kNone. Host is shared: 1-minute load average 12-67 during the runs (other users). Sync column: `all` = `--sync`, `1-in-20` = `--sync_write_one_in=20`, `none` = no sync.

| Profile | Sync | Cell | ops/s (median of 3) | min-max | vs N=1 kNone | mean write us | p99 write us | WAL appends | WAL syncs |
|---|---|---|---|---|---|---|---|---|---|
| S | all | N=1 kNone | 5425 | 5282-5490 | 1.00x | 11646 | 13984 | 6002 | 6002 |
| S | all | N=1 indexed | 5374 | 4871-5456 | 0.98x | 11716 | 14528 | 6007 | 6005 |
| S | all | N=8 | 20104 | 20098-20516 | 3.71x | 3163 | 6351 | 90202 | 48470 |
| S | all | N=16 | 22746 | 21715-23222 | 4.14x | 2794 | 5075 | 133766 | 80580 |
| S | 1-in-20 | N=1 kNone | 5659 | 5645-5672 | 1.00x | 11283 | 58960 | 6149 | 2042 |
| S | 1-in-20 | N=1 indexed | 5669 | 5624-5680 | 1.00x | 11270 | 60891 | 6027 | 1916 |
| S | 1-in-20 | N=8 | 21635 | 20743-21835 | 3.81x | 2940 | 6587 | 63675 | 20851 |
| S | 1-in-20 | N=16 | 24240 | 23984-24506 | 4.29x | 2620 | 6208 | 105691 | 38739 |
| S | none | N=1 kNone | 10627 | 10435-10702 | 1.00x | 6015 | 6595 | 6005 | 0 |
| S | none | N=1 indexed | 10631 | 10433-10650 | 1.00x | 6012 | 6598 | 6007 | 0 |
| S | none | N=8 | 48068 | 47452-48281 | 4.52x | 1318 | 2788 | 48464 | 0 |
| S | none | N=16 | 63757 | 63551-63974 | 6.00x | 992 | 1881 | 83100 | 0 |
| S-sync | all | N=1 kNone | 9725 | 9722-9781 | 1.00x | 6570 | 9790 | 6003 | 6003 |
| S-sync | all | N=1 indexed | 9776 | 9770-9792 | 1.00x | 6539 | 9621 | 6006 | 6004 |
| S-sync | all | N=8 | 28877 | 27685-29180 | 2.97x | 2208 | 4214 | 88995 | 46361 |
| S-sync | all | N=16 | 27734 | 26727-29899 | 2.85x | 2292 | 4318 | 134123 | 78895 |
| S-sync | 1-in-20 | N=1 kNone | 10263 | 10190-10338 | 1.00x | 6220 | 19308 | 6029 | 2525 |
| S-sync | 1-in-20 | N=1 indexed | 10330 | 10159-10355 | 1.00x | 6180 | 28946 | 6029 | 2329 |
| S-sync | 1-in-20 | N=8 | 29514 | 29500-29519 | 2.88x | 2152 | 5876 | 61844 | 21538 |
| S-sync | 1-in-20 | N=16 | 30808 | 30736-31239 | 3.02x | 2059 | 4387 | 103682 | 39121 |
| S-sync | none | N=1 kNone | 72763 | 72596-74166 | 1.00x | 873 | 1293 | 6013 | 0 |
| S-sync | none | N=1 indexed | 74786 | 72987-75086 | 1.01x | 850 | 1285 | 6016 | 0 |
| S-sync | none | N=8 | 123028 | 120951-124222 | 1.67x | 512 | 862 | 39044 | 0 |
| S-sync | none | N=16 | 133228 | 129421-133491 | 1.80x | 471 | 855 | 71038 | 0 |
| S, 16 threads | all | N=1 kNone | 4724 | 4387-4738 | 1.00x | 3346 | 6482 | 4022 | 4022 |
| S, 16 threads | all | N=1 indexed | 4713 | 4707-4736 | 1.00x | 3334 | 6478 | 3958 | 3956 |
| S, 16 threads | all | N=8 | 8494 | 8464-8529 | 1.80x | 1873 | 2895 | 40476 | 27290 |
| S, 16 threads | all | N=16 | 9294 | 9250-9323 | 1.97x | 1711 | 2876 | 44226 | 34317 |

All 84 runs exited 0. Command per cell:

```
db_bench --benchmarks=fillrandom --threads=64 --num=3000 --value_size=4096 \
  --num_column_families=64 --wal_partitions=<N> --partition_wal_usage=<none|partition_by_column_family> \
  --enable_pipelined_write=false --disable_auto_compactions=1 --statistics --histogram \
  --inject_wal_latency --wal_append_latency_us=200 --wal_sync_latency_us=200 \
  --wal_latency_jitter_us=20 --wal_latency_seed=1001 --seed=1001 \
  --wal_append_bandwidth_mbps=<50|0> --wal_sync_bandwidth_mbps=50 [--sync | --sync_write_one_in=20]
```

N=1 against upstream (default options, no partitioning flags, no latency injection): release `db_bench` of this stack against release `db_bench` of facebook/rocksdb e732049, five rounds, alternating which binary runs first, DB on /dev/shm.

| Workload | upstream e732049 ops/s (median) | min-max | this stack ops/s (median) | min-max | stack/upstream (median of per-round) |
|---|---|---|---|---|---|
| fillrandom, 64 threads x 20000, 64 CFs, 4 KiB values, no sync | 224575 | 219463-232611 | 220572 | 213377-226176 | 0.972x |
| fillrandom, 16 threads x 200000, 1 KiB values, --sync | 532901 | 524086-611361 | 530771 | 525389-541405 | 0.999x |

Per-round stack/upstream ratios: --sync 0.996, 0.999, 1.032, 1.000, 0.860; no sync 0.972, 1.007, 0.948, 0.951, 0.990. 1-minute load average 11-22 during the runs. All 20 runs exited 0. The earlier run of the same comparison on e591f5f measured 0.996x (--sync) and 0.979x (no sync).

Stress (db_stress crash test with the latency-injection FileSystem wired in):

`tools/db_crashtest.py` blackbox and whitebox, 1800 s each, at wal_partitions 1 and 8, on the stack rebased onto facebook/rocksdb eb12834 (fork 286fdab796, debug db_stress; the final stack differs only in clang-format line wrapping and in `tools/db_crashtest.py`/`db_crashtest_test.py`). Pinned: `--disable_wal=0 --partition_wal_usage=partition_by_column_family --enable_blob_direct_write=0 --best_efforts_recovery=0 --two_write_queues=0 --enable_pipelined_write=0 --unordered_write=0 --recycle_log_file_num=0 --track_and_verify_wals=0 --inplace_update_support=0 --use_optimistic_txn=0`, plus `--inject_wal_latency=1 --wal_append_latency_us=50 --wal_sync_latency_us=300 --wal_latency_jitter_us=50 --wal_append_bandwidth_mbps=200 --wal_sync_bandwidth_mbps=100`. Every db_stress command line in the logs was checked for WAL on, latency injection on and the intended wal_partitions; randomized overrides did not disable them.

| Mode | wal_partitions | db_stress command lines | Result |
|---|---|---|---|
| blackbox | 1 | 31 | exit 0 |
| blackbox | 8 | 31 | exit 0 |
| whitebox | 1 | 16 | exit 0 |
| whitebox | 8 | 26 | exit 0 |

The same runs on the previous base (fork f4c2cc3436 on e732049) also exited 0 (31/31/22/12 command lines). The two fbcode sandcastle crash-test command lines that failed on the previous version (ASAN and blackbox, with `read_fault_one_in=1000`) were rerun locally against this stack, three times each for 1200 s: no failure.

fbcode sandcastle crash tests:

The six `rocksdb-contrun.sky` crash-test workflows ran on stack top 32fe728cb06b, scheduled 2026-11-10 05:32 UTC. The final stack differs from it only in test code, one comment and one line break (the ASAN and format fixes below); db_stress is unchanged. All six passed.

| Workflow | Result | Finished (PST, 2026-11-10) |
|---|---|---|
| fbcode_blackbox_crash_test | pass | 00:57 |
| fbcode_asan_blackbox_crash_test | pass | 00:57 |
| fbcode_tsan_blackbox_crash_test | pass | 01:16 |
| fbcode_whitebox_crash_test | pass | 03:37 |
| fbcode_asan_whitebox_crash_test | pass | 03:37 |
| fbcode_tsan_whitebox_crash_test | pass | 03:28 |

Sandcastle jobs: 49539596750420932, 49539596750421833, 40532397491966602, 49539596750421523, 45035997124599077, 22518001256897652 (https://www.internalfb.com/intern/sandcastle/job/<id>/). On the previous submitted version two of these workflows had failed (the sandcastle P1 below); that fix is in this stack.

Comprehensive review (15 rounds, whole 39-diff stack):

Each round ran the comprehensive-diff-review protocol (read-only Opus reviewers; round 1 used four reviewers by area, later rounds one) against the cumulative stack, on facebook/rocksdb d6a7847 for rounds 1-7 and, after the rebase onto e591f5f (the RocksDB subtree of fbcode/warm), on the rebased stack for rounds 8-11, on facebook/rocksdb e732049 (fbcode/warm 4df7e0a0db7b) for rounds 12-13, on 9ce1bfb (fbcode/warm 37d097c1b953) for round 14 and on eb12834 (fbcode/master b1d9881f429e) for round 15. Rounds 14 and 15 reviewed the rebase delta. Rows marked sandcastle, external and crash test are defects found outside the review rounds and fixed the same way. Every P1/P2 was re-checked against the code, reproduced by a new test that fails first, fixed in the diff that introduced the code, and verified by a neuter (reverting the fix makes the test fail). Candidates are the fork's review folds of pwal/m6.

| Round | Candidate | P1/P2 found | Fixed in | Regression test |
|---|---|---|---|---|
| 1 | pwal/m6 69c13fc | 4 P2: CMake missed db/log_merge.cc and log_merge_test; a secondary could not open or catch up beside an indexed primary with async_wal_precreate; a damaged first record in a WAL with an intact head floor and no span made the DB unopenable; commit_bypass_memtable failed after Prepare at N>1 | D120624825 (CMake), D127093323 (async_wal_precreate sanitized off when partition_wal_usage != kNone), D120649665 (HeadBounded counts the WAL's own head floor), D123079329 (bypass falls back to the memtable commit at N>1) | DBSecondaryTest.IndexedPrimaryDisablesAsyncWalPrecreate; DBWalPartitionCoverageTest.DamagedFirstRecordAfterUpgradeToTwoPartitions; TransactionPartitionedWalTest.CommitBypassMemtableCommitsNormally |
| 2 | fold2 2e8c56707a8f | 2 P2: GetSortedWalFiles returned a false Corruption once coupled rotation retired an idle partition's metadata-only WAL that the MANIFEST tracks; GC24HistoryFloorScopeOnUpgrade still pinned the pre-fix outcome | D127093323, D127837663 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWals |
| 3 | fold3 8b6590498 | 1 P2: that fix was keyed to the opener's wal_partitions, so read-only or N=1 openers still got the Corruption. Writing its test exposed a read-only open with WAL tracking off hitting `assert(recovery_ctx != nullptr)` in Recover; fixed too | D127093323 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWalsReadOnly |
| 4 | fold5 c3c369362 | 1 P2: at N=1 indexed, a data-less current WAL got a cached synthetic start sequence 1, so GetUpdatesSince skipped the older WAL holding the requested sequence | D127093323 | DBWalIteratorTest.IndexedDataLessCurrentWalKeepsOlderWal |
| 5 | fold6 6e3ad3889 | None. The per-diff gate then failed WalPartitions8/WritePreparedTransactionTest.{WC_WP_ForwardCompatibility, WP_WC_DBBackwardCompatibility}: listing every metadata-only WAL changed GetSortedWalFiles after a flush; reworked to upstream listing semantics | D127093323 | the two WritePrepared tests, unmodified |
| 6 | fold7 376fac935 | 1 P2: the rework left MANIFEST-tracked metadata-only WALs out of GetSortedWalFiles, so a GetLiveFiles(flush_memtable=false) + GetSortedWalFiles copy failed to open ("Missing WAL with log number"). Now a tracked metadata-only WAL is listed (start sequence 1, not cached) and an untracked one is skipped | D127093323 | DBWritePartitionTest.LiveFilesAndSortedWalFilesCopyOpens |
| 7 | fold8 431f2a98e | None (1 P3, below) | | |
| 8 | rebased 188e02204b43 (onto e591f5f; two reviewers) | None | | |
| sandcastle | previous submitted version | 1 P1 (fbcode crash tests with `read_fault_one_in=1000`): an injected WAL read I/O error during recovery surfaced as `Corruption: WAL index merge: WAL <n> head damaged and unattested` in the merged replay, and the classification pass ignored it | D120624825 (the merger keeps the read's IOError), D121636079/D121674557 (classification returns it), D123928339 (merged replay returns the merger's error before the damage checks) | LogMergeTest.FailedReadKeepsTheReadError; DBWALIndexTest.ClassificationReadIOErrorFailsRecovery; DBWalPartitionCoverageTest.MergeReadIOErrorFailsWithTheReadError |
| 9 | 805ea60 | 2 P3 + 1 gap, fixed: sequential indexed replay replaced the read IOError with a generic one; the merger's error dropped the read's retryable/data-loss/scope attributes | D120415420, D120624825 | DBWALIndexTest.SequentialIndexedReplayReadIOErrorKeepsTheReadError; LogMergeTest.FailedReadKeepsTheReadErrorAttributes |
| external | D119751506 reviewer comment | 1 P2: with manual_wal_flush the burned-index void cover appended to the WAL buffer without wal_write_mutex_, racing an application FlushWAL | D119751506 (takes the mutex as WriteToWAL does), D122412677 (per-partition mutex) | DBWALIndexTest.BurnedWALIndexCoverHoldsWALMutexWithManualFlush |
| crash test | 805ea60 | 1 P2 (debug only): whitebox crash test at N=8 hit the FlushScheduler::Empty consistency assertion when another partition leader dequeued concurrently | D123079329 (Empty reads the head under the debug checking mutex; release builds unchanged) | DBWritePartitionTest.FlushSchedulerEmptyRacesAnotherLeadersDequeue |
| 10 | 12aad1d | 1 P2: statuses on the merged-recovery read-error path left unchecked (ASSERT_STATUS_CHECKED abort) | D120624825, D123551605, D123701876, D123928339, D123971668, D127093323 (holders permitted, ignored reports marked) | the read-error tests above under ASSERT_STATUS_CHECKED |
| 11 | 69a91e9 | None | | |
| fbcode CI | previous submitted version | 1 P2 (build): D120624825 declared two private fields (`last_sequence_index_`, `last_sequence_wal_`) first used in D120649665, so clang failed with -Werror,-Wunused-private-field at D120624825 | D120624825 (the fields move to D120649665; later diffs unchanged) | clang per-diff build gate |
| 12 | f4c2cc3436 (rebased onto e732049) | 1 P2 (tests): upstream's new TransactionTest.InplaceUpdateSupportRequiresWriteCommitted also runs in this stack's WalPartitions8 instantiation, where Open rejects its options; 3 deterministic failures | D127275775 (at wal_partitions > 1 the test asserts NotSupported) | the test itself: 3 failures before, 33/33 after |
| 12 (re-review) | 7fd6043 | None | | |
| fbcode CI | 7fd6043 | 1 P2 (ASAN, test-only): GC31FollowerExitGroup freed its local Env while the fixture's last options still pointed at it, so the next DestroyAndReopen read freed memory (heap-use-after-free in NGreaterThan1FollowerExitHandsFailureToLeader); and the rocks format check flagged a comment over 80 columns and one unjoined condition | D123701876 (the helper resets the fixture's env on exit); D121858039, D123079329, D123551605, D123971668 (clang-format output) | the test under ASAN: heap-use-after-free before, 4/4 and db_write_test 581/581 after; check-format.sh passes on all 39 diffs |
| strict status | b19275b | 1 P2 (ASSERT_STATUS_CHECKED, GitHub CI): 27 aborts from unchecked statuses: a reader report superseded by a more specific recovery error, a per-record pending report on early returns, the gate sync's covered path, a background-error return, an ingestion early return, and three test-side cases. Release behaviour unchanged | D120415420, D120649665, D123476301, D123701876, D123928339, D123971668, D127837663 | the ASSERT_STATUS_CHECKED suite: 27 aborts before, 0 after |
| 13 | f658359 | None | | |
| 14 | m6-rb10 (rebased onto 9ce1bfb) | 1 P2 (tests, from my rebase resolution): upstream's new kSortedHash option config was not skipped at wal_partitions > 1, where Open accepts only the SkipList memtable, so 7 WalPartitions8/ExternalSSTFileTestN tests walking ChangeOptions failed to reopen | D127275775 (kSortedHash joins the N>1 skip list) | the 7 tests: fail before, pass after |
| 15 | 286fdab796 (rebased onto eb12834) | 1 P2 (crash test): upstream meta#15626 moved the inplace_update_support sanitizing ahead of this stack's N>1 overrides, which turned allow_concurrent_memtable_write back on, so about 3% of default crash-test series failed DB::Open. Found while verifying it: the same overrides replaced explicitly passed flags and made `make db_crashtest_tests` fail in about 5 of 6 runs, already on the previous stack (1 more P2) | D126533194 (N>1 steering moved into gen_cmd_params, before command-line flags) | db_crashtest_test.py: 3 new tests, each failing with the old overrides |
| 15 (re-review) | 0d68d5f821 | 2 P2 + 1 P3 in that fix: test_secondary was still drawn per run, so wal_partitions flipped between runs and a secondary could open over partition WALs; an explicit --wal_partitions was not steered; the new test helper did not pin the trie index (about 4% flaky) | D126533194 | test_wal_partitions_stays_fixed_across_runs, test_explicit_wal_partitions_is_steered (each fails under its neuter); suite 89/89 in 40 runs |
| fbcode CI | V1.2 drafts (1686cdb39f) | 1 P2 (stack order, crash test): D126533194 is the first diff whose crash test draws wal_partitions > 1, but the db_stress LockWAL check that accepts GetCurrentWalFile() NotSupported at N>1 lived in this diff, so whitebox runs at D126533194 failed with "GetCurrentWalFile() failed: Not implemented" | D126533194 (the check moves down from this diff; the final tree is unchanged) | local blackbox at wal_partitions=8, lock_wal_one_in=2000: the old D126533194 fails on its 2nd run (192 errors), the new one passes 11/11 |

Final state: all 39 diffs at fork 1686cdb39f on facebook/rocksdb eb12834, each mirrored byte-identically into its fbsource diff on fbcode/master b1d9881f429e (master has since gained one RocksDB commit, c043e8dfa272, touching include/rocksdb/options.h about 180 lines from this stack's hunks). At 286fdab796 (the final stack differs only in clang-format line wrapping and the crash-test Python): per-diff clang gate for all 39 diffs; full make suite 11192/11192; clang TSan once 709/709 and 100x 2600/2600; ASSERT_STATUS_CHECKED suite with no failures from this stack (range_locking_test only, below); crash tests above. At 1686cdb39f: db_write_test 581/581, the gap-filler tests, `tools/db_crashtest_test.py` 89/89, and fbcode/rocks/sandcastle/check-format.sh at every diff. Totals: 1 P1 and 20 P2 fixed.

Open items (P3 or validation gaps, tracked as follow-ups, not fixed here):
- ASSERT_STATUS_CHECKED: range_locking_test fails in that build mode at upstream e732049 too; it is not part of this stack.
- Rebase gap (pre-existing): with recycle_log_file_num > 0, an indexed one-partition DB gets no WAL sequence-gap filler (upstream meta#15581 covers kNone only), so an ingestion gap at a WAL boundary can still stop point-in-time recovery there, as it did for every DB before meta#15581.
- Round 9 F-002 (P3): consumer head checks report a WAL read I/O error as NotSupported.
- Round 11 gap (low confidence, pre-existing): the void re-read during recovery can swallow a transient read IOError.
- TSan with the gcc 11 runtime (libtsan.so.0) reports false "double lock of a mutex" on any std::condition_variable::wait_for mutex, upstream TransactionDB code included, because it does not intercept pthread_cond_clockwait. Use clang TSan.
- Round 7 P3: after an open that writes supersession records without a dummy write (for example a WalFilter stop with avoid_flush_during_recovery=true), partition 0's untracked, data-less current WAL carries the supersession record. GetSortedWalFiles skips it, so a GetLiveFiles + GetSortedWalFiles copy could fail with "two live records share index". Checkpoint and BackupEngine are unaffected. Inferred from code, not reproduced.
- Round 2 P3: WriteRecoverableState at N>1 can stamp the cached recoverable state inside an open fence during an auto-resumed retryable WAL error.
- Round 1 P3s: the checkpoint/backup LockWAL race tests can stop on an ASSERT before joining their threads; GC31FollowerExitGroup orders writers with sleeps; standalone db_stress at N>1 trips on the default get_current_wal_file_one_in; checkpoint/backup at N>1 wait out a write stop.
- Gaps: an indexed DB with wal_compression still caches start sequence 1 for a data-less WAL (as upstream does for compression-only WALs); HeadFloor() for a member with no surviving data is the last progress bound read (no production-reachable loss found).

Reports (MetaMate):
- Round 1: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-69c13fcb72e2-20261107t093444z
- Round 2: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold2-2e8c56707a8f-20261107t175411z
- Round 3: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold3-8b6590498-20261107t185930z
- Round 4: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold5-c3c369362-20261107t192653z
- Round 5: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold6-6e3ad3889-20261107t193256z
- Round 6: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold7-376fac935-20261108t054421z
- Round 7: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold8-431f2a98e-20261108t055310z
- Round 11: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb2-69a91e9ba-20261110t022328z
- Round 13: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb8-f6583590ed-20261110t195418z
- Round 15 (final stack): https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb15-1686cdb39f-20261111t191953z

Changes visible to existing users:
- Removes DBOptions::experimental_allow_wal_partitions_for_testing, its "experimental_allow_wal_partitions_for_testing" options-string key (which no longer parses) and the C API functions rocksdb_options_set/get_experimental_allow_wal_partitions_for_testing. All were added earlier in this stack (D117251769) and never released.
- The --wal_partitions help text of db_bench and db_stress changed.

Test Plan:
M4 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 4974 tests, 0 failed.

M5 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of compaction_service_test, db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_wal_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 7324 tests, 0 failed.

M6 B.1: PASS (debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7340/7340).

Rebased stack (e591f5f): PASS. Debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7559/7559. Full make suite 10540/10540.

Rebased stack (e732049, fbcode/warm 4df7e0a0db7b) final: clang per-diff gates for all 39 diffs; full make suite 10576/10579 at f4c2cc3436 with the 3 round-12 failures fixed at 7fd6043 (transaction_test 3475/3475); clang TSan; crash tests and the two sandcastle repro command lines above. At b19275b: db_write_test under ASAN/UBSAN (clang) 581/581; clang per-diff gates for D121858039 through D123971668 rerun and pass; fbcode/rocks/sandcastle/check-format.sh passes at every diff.
fbcode sandcastle crash tests (blackbox and whitebox; plain, ASAN, TSAN): 6/6 pass on 32fe728cb06b.
Strict status (ASSERT_STATUS_CHECKED=1) suite at f658359: 0 aborts from this stack (27 before the fix).
Rebased stack (facebook/rocksdb eb12834, fbcode/master b1d9881f429e) final: clang per-diff gates for all 39 diffs; full make suite 11192/11192; clang TSan 709/709 once and 2600/2600 at 100x; ASSERT_STATUS_CHECKED with only range_locking_test failing (not touched by this stack); crash tests blackbox and whitebox at wal_partitions 1 and 8 exit 0; `tools/db_crashtest_test.py` 89/89; check-format.sh passes at every diff.

Differential Revision: https://phabricator.intern.facebook.com/D130396596
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Nov 19, 2026
Summary:
Pull Request resolved: meta#15226

Makes `DBImpl` the owner of WAL index allocation, and wires indexing into the write path.

WAL recovery treats `wal_index` order as the durable proxy for sequence-number order. Allocating the two with independent atomics lets concurrent partition writers reverse those orders, so truncating an index prefix could leave an undetectable hole in sequence space. `AllocateSequenceAndWALIndex` reserves the sequence block and, when a WAL record will be written, its `wal_index`, under one short DB-wide `InstrumentedMutex`. The assigned index is then passed into `log::Writer::AddRecord`.

A mutex was chosen over a 16-byte atomic so the future durability-watermark `RegisterPending` can join the same critical section. The lock covers only counter updates — batch merging, WAL append, compression, sync and all other I/O stay outside it. The `kNone` path never takes it. An exhausted counter fails the write inside the lock rather than wrapping, since wrapping would break the monotonicity ordering depends on.

Also binds `SetPartitionWALUsage` on each newly created WAL writer and emits the marker from `StartWALFile`, so both WAL-creation paths — DB open and WAL switch — are covered by one call site.

Sequence-only writes use the same allocator without consuming an index; `disableWAL` is covered directly. External-file ingestion already fences both write queues across its sequence assignment, so no indexed allocation can interleave with it. `two_write_queues` is rejected, since its second allocation site would need a broader ordering change. `kPartitionByColumnFamily` is not rejected: in this diff it means indexed records in one WAL file at a time, which is what this diff writes. Writing more than one WAL file at a time is the separate `wal_partitions` option (D117251769), which `DB::Open` rejects above 1.

Upstream's WAL sequence-gap filler (facebook/rocksdb meta#15581, `MaybeAddWalSeqnoGapFiller`) is skipped for indexed WALs: a filler would need a `wal_index` below the next batch's. So with `partition_wal_usage` other than `kNone` and `recycle_log_file_num > 0`, a `disableWAL` write still returns `InvalidArgument`, as every such write did before meta#15581, and `TracksWalSeqnoGaps()` leaves `next_seq_after_last_wal_record_` alone. The `recycle_log_file_num` comment in options.h says so. `WriteToWAL` and `WriteGroupToWAL` take the `wal_index` after upstream's `seq_inc`.

The counter is **not** restored across restarts — it starts at `kWALIndexStartNumber` on every open, so indices are unique among WALs written by one process, not for all time. This is reachable with plain writes rather than only in theory: any write after a reopen starts a second live WAL numbering from `kWALIndexStartNumber` again, and `WALIndexNumberingRestartsAcrossLiveWALs` pins that state so a future fix has to change the test deliberately. Harmless while nothing consumes the index; to be resolved before anything does.

The burned-index window from the diff below is wider here, because allocation now precedes write-group merging and payload preparation rather than happening inside `AddRecord`. It still spans no additional I/O, and the existing `TODO` continues to track it.

M1: Absorbs GC05 Q3: `test::CountIndexedWALFiles` + 8 N=1 consumer tests (checkpoint, backup, secondary, wal x2, log_iter, repair, ldb). No consumer code fix.

To limit false sharing on the allocation path, `VersionSet::last_sequence_` and `last_allocated_sequence_` are each aligned to their own cache line, and `sequence_wal_index_mutex_` shares a cache line only with `next_wal_index_`, the state it guards. Debug-only hooks (`TEST_AllocateSequenceAndWALIndex`, `TEST_SetNextWALIndex`, `TEST_SequenceWalIndexMutexTakes`) support the new tests.

Changes visible to existing users:
- In VersionSet, `last_sequence_` and `last_allocated_sequence_` now each start their own cache line. This changes the memory layout of the sequence counters that every writer and reader touches, at any setting, and makes VersionSet up to about two cache lines larger.
- Each DBImpl gains a cache-line-aligned mutex and a counter (`sequence_wal_index_mutex_`, `next_wal_index_`). The mutex is never taken at kNone.

Test Plan:
DB-level tests in `db/db_wal_test.cc`, in a new `DBWALIndexTest` fixture (13 tests):

- `TwoWriteQueuesIsRejected` — `DB::Open` returns `NotSupported`.
- `SequenceAndWALIndexAllocationIsAtomic` — concurrent allocation never reverses sequence and index order relative to each other.
- `DisableWALDoesNotConsumeWALIndex` — a `disableWAL` write advances the sequence but not the index.
- `IngestExternalFileDoesNotConsumeWALIndex` — ingestion assigns sequence numbers without consuming an index.
- `IndexedWALReplaysThroughRecovery` — 16 keys survive two reopens.
- `ReadOnlyOpenReadsIndexedWAL` — a read-only open recovers an indexed WAL, with the option on and with it off.
- `WalFilterSeesEveryIndexedRecordOnce` — a `WalFilter` sees every record of two indexed WALs exactly once, in sequence order.
- `WALIndexNumberingRestartsAcrossLiveWALs` — after a reopen and a second round of writes, both live WALs carry `[kWALIndexStartNumber .. +15]`, pinning the documented restart-seeding limitation.
- `DefaultUsageWritesNoIndexedRecords` — with `kNone`, no indexed or marker record type reaches the WAL.
- `IndexedWALCarriesWALIndexOnDisk` — the marker is the first physical record, all 16 data records use indexed types, and the decoded indices are exactly `[kWALIndexStartNumber .. +15]`.
- `SwitchedWALCarriesWALIndexOnDisk` — after `TEST_SwitchWAL()`, the new WAL starts with the marker, its 16 data records use indexed types, and its indices continue from the old WAL (`kWALIndexStartNumber + 16 ..`), so the WAL-switch path is covered as well as Open.
- `ExhaustedWALIndexFailsOnlyWALWrites` — with the counter set to `UINT64_MAX` via `TEST_SetNextWALIndex`, a `disableWAL` write still succeeds and the next WAL write fails with `Corruption: WAL index exhausted`.
- `RecycledIndexedWALWritesNoSeqnoGapFiller` — with `recycle_log_file_num = 3`, an indexed DB rejects a `disableWAL` write with `InvalidArgument` and writes no gap filler into a WAL that starts past an ingested file's sequence number; `kNone` accepts the write and writes the filler. All keys survive a reopen. Neutered separately, the `WriteImpl` check and the `TracksWalSeqnoGaps()` indexing term each make it fail.

Consumer tests (N=1), one per consumer, using the new `test::CountIndexedWALFiles`: `DBWalIteratorTest.IndexedWALsInArchiveAndLive`, `DBSecondaryTest.CatchUpReadsIndexedWAL`, `RepairTest.UnflushedIndexedWAL`, `LdbCmdTest.DumpWalPrintsIndexedRecords`, `BackupEngineTest.BackupWithoutFlushCopiesIndexedWAL`, `CheckpointTest.CheckpointCopiesIndexedWAL` (plus `ReadOnlyOpenReadsIndexedWAL` and `WalFilterSeesEveryIndexedRecordOnce` above).

`IndexedWALCarriesWALIndexOnDisk` was verified to fail without the wiring: disabling the binding makes it report all-zero indices, while the replay tests still pass — a vanilla WAL replays fine, which is why the on-disk assertion is the one that tests this diff.

(The `DBWALIndexTest` run recorded here earlier showed 8 tests and predates the last four tests above; current results for this diff are in the M3 B.1 line at the end.)

```
$ buck2 run fbcode//internal_repo_rocksdb/repo:log_test
[==========] 299 tests from 4 test suites ran.
[  PASSED  ] 299 tests.
```

**Concurrent write throughput.** The earlier `fillseq --threads=1` number could not say anything about `sequence_wal_index_mutex_`, whose entire risk is contention. Measured with an opt build, DB on tmpfs so disk variance does not swamp the signal, `none` and the indexed format run alternately on the same binary. That A/B is clean in the sense that the `kNone` path never enters the allocator, and alternating makes the runs paired, so each pair shares its machine conditions.

```
$ db_bench --benchmarks=fillrandom --threads=N --num=250000 --db=/dev/shm/... \
      --partition_wal_usage={none,partition_by_column_family}      # 166-core host, 22 pairs each

threads=16   none median 722,632 ops/s   indexed median 687,920 ops/s
             paired delta: median -4.1%, mean -3.6%, range -11.2%..+4.9%
             indexed slower in 18 of 22 pairs   (sign test p = 0.0022, one-sided)

threads=64   none median 1,116,295 ops/s  indexed median 1,018,020 ops/s
             paired delta: median -8.8%, mean -9.2%, range -21.3%..+2.1%
             indexed slower in 21 of 22 pairs   (sign test p < 0.0001, one-sided)
```

The indexed runs used the spelling `record_ordering_single_file`, which was removed when the enum went to two values and no longer parses. The same one-file indexed format is now `partition_by_column_family` with the default `wal_partitions=1`. The numbers above were not re-measured.

The paired counts are the result, not the medians: at 16 threads the two ranges overlap almost completely, so the medians on their own look like noise. It took 22 pairs to show they are not. The first 7 pairs gave 4/7 at 16 threads (p = 0.5, indistinguishable from a coin flip) and 6/7 at 64 -- that sample was simply too small, and reporting only its medians would have overstated what had been measured.

The gap widens with thread count, which is consistent with contention but is not isolated to it. The A/B covers the whole indexed path, not the lock: the 8-byte prefix on every record and the marker are in there too. And one effect cuts the other way -- larger write groups at higher thread counts mean the mutex is taken once per group rather than once per write, so per-write lock cost should *fall* as threads rise. Naming the mutex specifically would need a third build with the lock removed and the record format unchanged; that has not been done.

With one WAL file at a time (`wal_partitions=1`) the exposure is bounded regardless: every write already funnels through a serialized group leader. It matters for what comes next -- under partitioning N leaders hit the allocator concurrently and it becomes the one global serialization point in an otherwise parallel write path. Recording the number here so that work starts from a measurement.

An earlier attempt with the DB on the default disk-backed path produced a 19-22% run-to-run spread that straddled zero -- one iteration had the indexed path faster -- and could not resolve an effect this size. The tmpfs numbers above are what the comparison rests on.

`arc lint -a` on all changed files — no issues.

Formatting verified per file rather than asserted: `clang-format <file> | diff - <file>` is empty for every changed file, using the repo-pinned `tools/third-party/clang-format/clang-format`.

M1: consumer tests run in tip suites (7870/0).
M1 re-verification (2026-10-20, after rebasing the stack onto master f0c3a35689fc and clang-formatting): per-diff gate at this diff passed (CI format check, `rocksdb_lib` build, touched test targets); tip suites 8126/0; N=1 byte identity equals T0.

M3 B.1 at this diff (clang-format 21.1.2 on its changed lines, make check-sources, debug build, touched test binaries): PASS; backup_engine_test + checkpoint_test + db_log_iter_test + db_secondary_test + db_wal_test + ldb_cmd_test + repair_test: 2281 pass.

M5 fold: Absorbs 10 A.1 entries (GC28 5, GC31 4, GC29b 1): GC28 Q8: SequenceWalIndexLock, its debug counter and TEST_SequenceWalIndexMutexTakes, the scope block of AllocateSequenceAndWALIndex (its D119600943 slice), the allocation-section comment; GC31 Q2 (c): VersionSet cache lines, sequence_wal_index_mutex_ with next_wal_index_. Not here after B.1: GC31#362 goes to D123701876 (X26-M5, X33-M5). Exceptions: X28-M5: GC31#363 (db_impl.h) split: removing the old next_wal_index_ declaration goes with GC31#361's new one at D119600943 (else it is declared twice), the cache-line moves stay at D123701876. Hand-splits (rows below the hunk's top row get their slice by a per-row edit): GC28#46 (AllocateSequenceAndWALIndex re-indent, H5): D119600943 takes the scope block, SequenceWalIndexLock, the Allocated sync point and re-indents its lines; D123079329 re-indents the three lines it brings in; D123476301 registers both trackers inside the scope.

M5 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of backup_engine_test, checkpoint_test, db_log_iter_test, db_secondary_test, db_wal_test, ldb_cmd_test, repair_test, ldb); 2281 tests, 0 failed.

Reviewers: kinbertchou, xbw, huixiao

Subscribers: jewoongh, rbanerjee2, anand76, huixiao

Differential Revision: https://phabricator.intern.facebook.com/D119600943
JustinGaoF pushed a commit to JustinGaoF/rocksdb that referenced this pull request Nov 19, 2026
…n builds

Summary:
The flip of the PartitionWAL stack (GC18 Q1-Q5). DB::Open accepts
wal_partitions > 1 with an indexing partition_wal_usage in release and
debug builds, with no sync point and no opt-in. kNone with N>1 and every
other M1.4 rejection still fail with their exact Status. The
wal_partitions doc and the release notes describe the shipped behaviour
and the rollout order (readers first).

Removes:
- the N>1 gate in DBImpl::ValidateOptions and its debug sync point
  DBImpl::ValidateOptions:AllowWalPartitions;
- the GC13 opt-in experimental_allow_wal_partitions_for_testing
  (D-G18k (i)): the option, its OPTIONS-map entry, Dump line, generated C
  accessors (two "removed" entries are added to tools/c_api_gen/api_compatibility_allowlist.json); db_bench, db_stress and
  test::SetWalPartitions stop setting it;
- every use of the hook in tests and tools, including the hooks that
  tests folded below this commit carry at M4 (exception X14:
  FailedSyncPrepareLeavesNoStaleFence, GC23TimestampedSnapshotsSurviveFlushStress,
  GC19TornFirstRecordInBrandNewNTwoDbModes, CreateBrandNewPartitionedDb,
  GC23FloorOffForLaterGenerationHeads, GC24HistoryFloorScopeOnUpgrade) and
  the original hooks of SyncPrepareAfterSyncCommitSurvivesCrash,
  FU14SnapshotRace and FU14H6TornFirstRecordInBrandNewNTwoDb (GC26 Q5(d)).

Adds db_wal_partitions_open_test (GC18 Q1, with GC20 Q9's edits), GC20
Q9's "with indexing it opens" leg of WalPartitionsValidation (exception
X6), GC23 Q8's wal_partitions doc sentences (exception X6), and the
release notes unreleased_history/new_features/wal_partitions.md,
behavior_changes/partition_wal_sync_visibility.md (GC25) and
behavior_changes/partition_wal_recovery_modes.md (GC26) (exception X19:
they describe behaviour production builds reach only from this commit).

Recorded exception: this commit stays a standalone diff on top of the
stack and is never folded (GC18 round decision, design audit G3-C-2), so it
can be reviewed, landed and reverted alone, and N>1 never becomes legal
partway up the stack.

M5 fold: Absorbs 10 A.1 entries (GC28 1, GC27 3, GC30 2, GC29a 2, GC31 1, GC32 1): the five new release-note files (X19-M5); the post-flip wal_partitions doc lines (GC27, GC30, GC29a); wal_partitions.md. Exceptions: X19-M5. Release notes added here (X19-M5): bug_fixes/partition_wal_recovery_and_visibility_fixes.md, new_features/partition_wal_file_scoped_resume.md, performance_improvements/partition_wal_targeted_gate_sync.md, performance_improvements/partition_wal_write_path_locks.md, performance_improvements/partition_wal_write_pipeline.md. Removes the X14-M5 hook lines: the AllowWalPartitions callbacks D123079329, D123701876, D123928339, D123971668, D127093323 and D127275775 added to their folded N>1 tests.

M6 fold: removes the `DBImpl::ValidateOptions:AllowWalPartitions` hook lines added below the flip to the GC34 Q1 tests (`RunReplayedPrepareIsNotCut`); no other change.

Benchmark (rebased stack, paired and interleaved):

Release `db_bench` built at the rebased stack (fork f4c2cc3436 on facebook/rocksdb e732049; the final 7fd6043 differs only in transaction_test.cc). Workload: `fillrandom`, 3000 ops per thread, 4 KiB values, 64 column families, pipelined write off, auto compactions off, DB on /dev/shm. The latency-injection FileSystem adds a 200 us WAL append latency and a 200 us WAL sync latency (20 us jitter, fixed seed 1001). Profile S caps WAL append and sync bandwidth at 50 MB/s each. Profile S-sync caps only sync bandwidth (50 MB/s). There are three rounds, and each round runs every cell, rotating the cell order. The table reports the median of the three runs (min-max across runs). The ratio is the median of the per-round ratios against N=1 kNone. Host is shared: 1-minute load average 12-67 during the runs (other users). Sync column: `all` = `--sync`, `1-in-20` = `--sync_write_one_in=20`, `none` = no sync.

| Profile | Sync | Cell | ops/s (median of 3) | min-max | vs N=1 kNone | mean write us | p99 write us | WAL appends | WAL syncs |
|---|---|---|---|---|---|---|---|---|---|
| S | all | N=1 kNone | 5425 | 5282-5490 | 1.00x | 11646 | 13984 | 6002 | 6002 |
| S | all | N=1 indexed | 5374 | 4871-5456 | 0.98x | 11716 | 14528 | 6007 | 6005 |
| S | all | N=8 | 20104 | 20098-20516 | 3.71x | 3163 | 6351 | 90202 | 48470 |
| S | all | N=16 | 22746 | 21715-23222 | 4.14x | 2794 | 5075 | 133766 | 80580 |
| S | 1-in-20 | N=1 kNone | 5659 | 5645-5672 | 1.00x | 11283 | 58960 | 6149 | 2042 |
| S | 1-in-20 | N=1 indexed | 5669 | 5624-5680 | 1.00x | 11270 | 60891 | 6027 | 1916 |
| S | 1-in-20 | N=8 | 21635 | 20743-21835 | 3.81x | 2940 | 6587 | 63675 | 20851 |
| S | 1-in-20 | N=16 | 24240 | 23984-24506 | 4.29x | 2620 | 6208 | 105691 | 38739 |
| S | none | N=1 kNone | 10627 | 10435-10702 | 1.00x | 6015 | 6595 | 6005 | 0 |
| S | none | N=1 indexed | 10631 | 10433-10650 | 1.00x | 6012 | 6598 | 6007 | 0 |
| S | none | N=8 | 48068 | 47452-48281 | 4.52x | 1318 | 2788 | 48464 | 0 |
| S | none | N=16 | 63757 | 63551-63974 | 6.00x | 992 | 1881 | 83100 | 0 |
| S-sync | all | N=1 kNone | 9725 | 9722-9781 | 1.00x | 6570 | 9790 | 6003 | 6003 |
| S-sync | all | N=1 indexed | 9776 | 9770-9792 | 1.00x | 6539 | 9621 | 6006 | 6004 |
| S-sync | all | N=8 | 28877 | 27685-29180 | 2.97x | 2208 | 4214 | 88995 | 46361 |
| S-sync | all | N=16 | 27734 | 26727-29899 | 2.85x | 2292 | 4318 | 134123 | 78895 |
| S-sync | 1-in-20 | N=1 kNone | 10263 | 10190-10338 | 1.00x | 6220 | 19308 | 6029 | 2525 |
| S-sync | 1-in-20 | N=1 indexed | 10330 | 10159-10355 | 1.00x | 6180 | 28946 | 6029 | 2329 |
| S-sync | 1-in-20 | N=8 | 29514 | 29500-29519 | 2.88x | 2152 | 5876 | 61844 | 21538 |
| S-sync | 1-in-20 | N=16 | 30808 | 30736-31239 | 3.02x | 2059 | 4387 | 103682 | 39121 |
| S-sync | none | N=1 kNone | 72763 | 72596-74166 | 1.00x | 873 | 1293 | 6013 | 0 |
| S-sync | none | N=1 indexed | 74786 | 72987-75086 | 1.01x | 850 | 1285 | 6016 | 0 |
| S-sync | none | N=8 | 123028 | 120951-124222 | 1.67x | 512 | 862 | 39044 | 0 |
| S-sync | none | N=16 | 133228 | 129421-133491 | 1.80x | 471 | 855 | 71038 | 0 |
| S, 16 threads | all | N=1 kNone | 4724 | 4387-4738 | 1.00x | 3346 | 6482 | 4022 | 4022 |
| S, 16 threads | all | N=1 indexed | 4713 | 4707-4736 | 1.00x | 3334 | 6478 | 3958 | 3956 |
| S, 16 threads | all | N=8 | 8494 | 8464-8529 | 1.80x | 1873 | 2895 | 40476 | 27290 |
| S, 16 threads | all | N=16 | 9294 | 9250-9323 | 1.97x | 1711 | 2876 | 44226 | 34317 |

All 84 runs exited 0. Command per cell:

```
db_bench --benchmarks=fillrandom --threads=64 --num=3000 --value_size=4096 \
  --num_column_families=64 --wal_partitions=<N> --partition_wal_usage=<none|partition_by_column_family> \
  --enable_pipelined_write=false --disable_auto_compactions=1 --statistics --histogram \
  --inject_wal_latency --wal_append_latency_us=200 --wal_sync_latency_us=200 \
  --wal_latency_jitter_us=20 --wal_latency_seed=1001 --seed=1001 \
  --wal_append_bandwidth_mbps=<50|0> --wal_sync_bandwidth_mbps=50 [--sync | --sync_write_one_in=20]
```

N=1 against upstream (default options, no partitioning flags, no latency injection): release `db_bench` of this stack against release `db_bench` of facebook/rocksdb e732049, five rounds, alternating which binary runs first, DB on /dev/shm.

| Workload | upstream e732049 ops/s (median) | min-max | this stack ops/s (median) | min-max | stack/upstream (median of per-round) |
|---|---|---|---|---|---|
| fillrandom, 64 threads x 20000, 64 CFs, 4 KiB values, no sync | 224575 | 219463-232611 | 220572 | 213377-226176 | 0.972x |
| fillrandom, 16 threads x 200000, 1 KiB values, --sync | 532901 | 524086-611361 | 530771 | 525389-541405 | 0.999x |

Per-round stack/upstream ratios: --sync 0.996, 0.999, 1.032, 1.000, 0.860; no sync 0.972, 1.007, 0.948, 0.951, 0.990. 1-minute load average 11-22 during the runs. All 20 runs exited 0. The earlier run of the same comparison on e591f5f measured 0.996x (--sync) and 0.979x (no sync).

Stress (db_stress crash test with the latency-injection FileSystem wired in):

`tools/db_crashtest.py` blackbox and whitebox, 1800 s each, at wal_partitions 1 and 8, on the stack rebased onto facebook/rocksdb eb12834 (fork 286fdab796, debug db_stress; the final stack differs only in clang-format line wrapping and in `tools/db_crashtest.py`/`db_crashtest_test.py`). Pinned: `--disable_wal=0 --partition_wal_usage=partition_by_column_family --enable_blob_direct_write=0 --best_efforts_recovery=0 --two_write_queues=0 --enable_pipelined_write=0 --unordered_write=0 --recycle_log_file_num=0 --track_and_verify_wals=0 --inplace_update_support=0 --use_optimistic_txn=0`, plus `--inject_wal_latency=1 --wal_append_latency_us=50 --wal_sync_latency_us=300 --wal_latency_jitter_us=50 --wal_append_bandwidth_mbps=200 --wal_sync_bandwidth_mbps=100`. Every db_stress command line in the logs was checked for WAL on, latency injection on and the intended wal_partitions; randomized overrides did not disable them.

| Mode | wal_partitions | db_stress command lines | Result |
|---|---|---|---|
| blackbox | 1 | 31 | exit 0 |
| blackbox | 8 | 31 | exit 0 |
| whitebox | 1 | 16 | exit 0 |
| whitebox | 8 | 26 | exit 0 |

The same runs on the previous base (fork f4c2cc3436 on e732049) also exited 0 (31/31/22/12 command lines). The two fbcode sandcastle crash-test command lines that failed on the previous version (ASAN and blackbox, with `read_fault_one_in=1000`) were rerun locally against this stack, three times each for 1200 s: no failure.

fbcode sandcastle crash tests:

The six `rocksdb-contrun.sky` crash-test workflows ran on stack top 32fe728cb06b, scheduled 2026-11-10 05:32 UTC. The final stack differs from it only in test code, one comment and one line break (the ASAN and format fixes below); db_stress is unchanged. All six passed.

| Workflow | Result | Finished (PST, 2026-11-10) |
|---|---|---|
| fbcode_blackbox_crash_test | pass | 00:57 |
| fbcode_asan_blackbox_crash_test | pass | 00:57 |
| fbcode_tsan_blackbox_crash_test | pass | 01:16 |
| fbcode_whitebox_crash_test | pass | 03:37 |
| fbcode_asan_whitebox_crash_test | pass | 03:37 |
| fbcode_tsan_whitebox_crash_test | pass | 03:28 |

Sandcastle jobs: 49539596750420932, 49539596750421833, 40532397491966602, 49539596750421523, 45035997124599077, 22518001256897652 (https://www.internalfb.com/intern/sandcastle/job/<id>/). On the previous submitted version two of these workflows had failed (the sandcastle P1 below); that fix is in this stack.

Comprehensive review (15 rounds, whole 39-diff stack):

Each round ran the comprehensive-diff-review protocol (read-only Opus reviewers; round 1 used four reviewers by area, later rounds one) against the cumulative stack, on facebook/rocksdb d6a7847 for rounds 1-7 and, after the rebase onto e591f5f (the RocksDB subtree of fbcode/warm), on the rebased stack for rounds 8-11, on facebook/rocksdb e732049 (fbcode/warm 4df7e0a0db7b) for rounds 12-13, on 9ce1bfb (fbcode/warm 37d097c1b953) for round 14 and on eb12834 (fbcode/master b1d9881f429e) for round 15. Rounds 14 and 15 reviewed the rebase delta. Rows marked sandcastle, external and crash test are defects found outside the review rounds and fixed the same way. Every P1/P2 was re-checked against the code, reproduced by a new test that fails first, fixed in the diff that introduced the code, and verified by a neuter (reverting the fix makes the test fail). Candidates are the fork's review folds of pwal/m6.

| Round | Candidate | P1/P2 found | Fixed in | Regression test |
|---|---|---|---|---|
| 1 | pwal/m6 69c13fc | 4 P2: CMake missed db/log_merge.cc and log_merge_test; a secondary could not open or catch up beside an indexed primary with async_wal_precreate; a damaged first record in a WAL with an intact head floor and no span made the DB unopenable; commit_bypass_memtable failed after Prepare at N>1 | D120624825 (CMake), D127093323 (async_wal_precreate sanitized off when partition_wal_usage != kNone), D120649665 (HeadBounded counts the WAL's own head floor), D123079329 (bypass falls back to the memtable commit at N>1) | DBSecondaryTest.IndexedPrimaryDisablesAsyncWalPrecreate; DBWalPartitionCoverageTest.DamagedFirstRecordAfterUpgradeToTwoPartitions; TransactionPartitionedWalTest.CommitBypassMemtableCommitsNormally |
| 2 | fold2 2e8c56707a8f | 2 P2: GetSortedWalFiles returned a false Corruption once coupled rotation retired an idle partition's metadata-only WAL that the MANIFEST tracks; GC24HistoryFloorScopeOnUpgrade still pinned the pre-fix outcome | D127093323, D127837663 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWals |
| 3 | fold3 8b6590498 | 1 P2: that fix was keyed to the opener's wal_partitions, so read-only or N=1 openers still got the Corruption. Writing its test exposed a read-only open with WAL tracking off hitting `assert(recovery_ctx != nullptr)` in Recover; fixed too | D127093323 | DBWritePartitionTest.SortedWalFilesListsIdlePartitionWalsReadOnly |
| 4 | fold5 c3c369362 | 1 P2: at N=1 indexed, a data-less current WAL got a cached synthetic start sequence 1, so GetUpdatesSince skipped the older WAL holding the requested sequence | D127093323 | DBWalIteratorTest.IndexedDataLessCurrentWalKeepsOlderWal |
| 5 | fold6 6e3ad3889 | None. The per-diff gate then failed WalPartitions8/WritePreparedTransactionTest.{WC_WP_ForwardCompatibility, WP_WC_DBBackwardCompatibility}: listing every metadata-only WAL changed GetSortedWalFiles after a flush; reworked to upstream listing semantics | D127093323 | the two WritePrepared tests, unmodified |
| 6 | fold7 376fac935 | 1 P2: the rework left MANIFEST-tracked metadata-only WALs out of GetSortedWalFiles, so a GetLiveFiles(flush_memtable=false) + GetSortedWalFiles copy failed to open ("Missing WAL with log number"). Now a tracked metadata-only WAL is listed (start sequence 1, not cached) and an untracked one is skipped | D127093323 | DBWritePartitionTest.LiveFilesAndSortedWalFilesCopyOpens |
| 7 | fold8 431f2a98e | None (1 P3, below) | | |
| 8 | rebased 188e02204b43 (onto e591f5f; two reviewers) | None | | |
| sandcastle | previous submitted version | 1 P1 (fbcode crash tests with `read_fault_one_in=1000`): an injected WAL read I/O error during recovery surfaced as `Corruption: WAL index merge: WAL <n> head damaged and unattested` in the merged replay, and the classification pass ignored it | D120624825 (the merger keeps the read's IOError), D121636079/D121674557 (classification returns it), D123928339 (merged replay returns the merger's error before the damage checks) | LogMergeTest.FailedReadKeepsTheReadError; DBWALIndexTest.ClassificationReadIOErrorFailsRecovery; DBWalPartitionCoverageTest.MergeReadIOErrorFailsWithTheReadError |
| 9 | 805ea60 | 2 P3 + 1 gap, fixed: sequential indexed replay replaced the read IOError with a generic one; the merger's error dropped the read's retryable/data-loss/scope attributes | D120415420, D120624825 | DBWALIndexTest.SequentialIndexedReplayReadIOErrorKeepsTheReadError; LogMergeTest.FailedReadKeepsTheReadErrorAttributes |
| external | D119751506 reviewer comment | 1 P2: with manual_wal_flush the burned-index void cover appended to the WAL buffer without wal_write_mutex_, racing an application FlushWAL | D119751506 (takes the mutex as WriteToWAL does), D122412677 (per-partition mutex) | DBWALIndexTest.BurnedWALIndexCoverHoldsWALMutexWithManualFlush |
| crash test | 805ea60 | 1 P2 (debug only): whitebox crash test at N=8 hit the FlushScheduler::Empty consistency assertion when another partition leader dequeued concurrently | D123079329 (Empty reads the head under the debug checking mutex; release builds unchanged) | DBWritePartitionTest.FlushSchedulerEmptyRacesAnotherLeadersDequeue |
| 10 | 12aad1d | 1 P2: statuses on the merged-recovery read-error path left unchecked (ASSERT_STATUS_CHECKED abort) | D120624825, D123551605, D123701876, D123928339, D123971668, D127093323 (holders permitted, ignored reports marked) | the read-error tests above under ASSERT_STATUS_CHECKED |
| 11 | 69a91e9 | None | | |
| fbcode CI | previous submitted version | 1 P2 (build): D120624825 declared two private fields (`last_sequence_index_`, `last_sequence_wal_`) first used in D120649665, so clang failed with -Werror,-Wunused-private-field at D120624825 | D120624825 (the fields move to D120649665; later diffs unchanged) | clang per-diff build gate |
| 12 | f4c2cc3436 (rebased onto e732049) | 1 P2 (tests): upstream's new TransactionTest.InplaceUpdateSupportRequiresWriteCommitted also runs in this stack's WalPartitions8 instantiation, where Open rejects its options; 3 deterministic failures | D127275775 (at wal_partitions > 1 the test asserts NotSupported) | the test itself: 3 failures before, 33/33 after |
| 12 (re-review) | 7fd6043 | None | | |
| fbcode CI | 7fd6043 | 1 P2 (ASAN, test-only): GC31FollowerExitGroup freed its local Env while the fixture's last options still pointed at it, so the next DestroyAndReopen read freed memory (heap-use-after-free in NGreaterThan1FollowerExitHandsFailureToLeader); and the rocks format check flagged a comment over 80 columns and one unjoined condition | D123701876 (the helper resets the fixture's env on exit); D121858039, D123079329, D123551605, D123971668 (clang-format output) | the test under ASAN: heap-use-after-free before, 4/4 and db_write_test 581/581 after; check-format.sh passes on all 39 diffs |
| strict status | b19275b | 1 P2 (ASSERT_STATUS_CHECKED, GitHub CI): 27 aborts from unchecked statuses: a reader report superseded by a more specific recovery error, a per-record pending report on early returns, the gate sync's covered path, a background-error return, an ingestion early return, and three test-side cases. Release behaviour unchanged | D120415420, D120649665, D123476301, D123701876, D123928339, D123971668, D127837663 | the ASSERT_STATUS_CHECKED suite: 27 aborts before, 0 after |
| 13 | f658359 | None | | |
| 14 | m6-rb10 (rebased onto 9ce1bfb) | 1 P2 (tests, from my rebase resolution): upstream's new kSortedHash option config was not skipped at wal_partitions > 1, where Open accepts only the SkipList memtable, so 7 WalPartitions8/ExternalSSTFileTestN tests walking ChangeOptions failed to reopen | D127275775 (kSortedHash joins the N>1 skip list) | the 7 tests: fail before, pass after |
| 15 | 286fdab796 (rebased onto eb12834) | 1 P2 (crash test): upstream meta#15626 moved the inplace_update_support sanitizing ahead of this stack's N>1 overrides, which turned allow_concurrent_memtable_write back on, so about 3% of default crash-test series failed DB::Open. Found while verifying it: the same overrides replaced explicitly passed flags and made `make db_crashtest_tests` fail in about 5 of 6 runs, already on the previous stack (1 more P2) | D126533194 (N>1 steering moved into gen_cmd_params, before command-line flags) | db_crashtest_test.py: 3 new tests, each failing with the old overrides |
| 15 (re-review) | 0d68d5f821 | 2 P2 + 1 P3 in that fix: test_secondary was still drawn per run, so wal_partitions flipped between runs and a secondary could open over partition WALs; an explicit --wal_partitions was not steered; the new test helper did not pin the trie index (about 4% flaky) | D126533194 | test_wal_partitions_stays_fixed_across_runs, test_explicit_wal_partitions_is_steered (each fails under its neuter); suite 89/89 in 40 runs |
| fbcode CI | V1.2 drafts (1686cdb39f) | 1 P2 (stack order, crash test): D126533194 is the first diff whose crash test draws wal_partitions > 1, but the db_stress LockWAL check that accepts GetCurrentWalFile() NotSupported at N>1 lived in this diff, so whitebox runs at D126533194 failed with "GetCurrentWalFile() failed: Not implemented" | D126533194 (the check moves down from this diff; the final tree is unchanged) | local blackbox at wal_partitions=8, lock_wal_one_in=2000: the old D126533194 fails on its 2nd run (192 errors), the new one passes 11/11 |

Final state: all 39 diffs at fork 1686cdb39f on facebook/rocksdb eb12834, each mirrored byte-identically into its fbsource diff on fbcode/master b1d9881f429e (master has since gained one RocksDB commit, c043e8dfa272, touching include/rocksdb/options.h about 180 lines from this stack's hunks). At 286fdab796 (the final stack differs only in clang-format line wrapping and the crash-test Python): per-diff clang gate for all 39 diffs; full make suite 11192/11192; clang TSan once 709/709 and 100x 2600/2600; ASSERT_STATUS_CHECKED suite with no failures from this stack (range_locking_test only, below); crash tests above. At 1686cdb39f: db_write_test 581/581, the gap-filler tests, `tools/db_crashtest_test.py` 89/89, and fbcode/rocks/sandcastle/check-format.sh at every diff. Totals: 1 P1 and 20 P2 fixed.

Open items (P3 or validation gaps, tracked as follow-ups, not fixed here):
- ASSERT_STATUS_CHECKED: range_locking_test fails in that build mode at upstream e732049 too; it is not part of this stack.
- Rebase gap (pre-existing): with recycle_log_file_num > 0, an indexed one-partition DB gets no WAL sequence-gap filler (upstream meta#15581 covers kNone only), so an ingestion gap at a WAL boundary can still stop point-in-time recovery there, as it did for every DB before meta#15581.
- Round 9 F-002 (P3): consumer head checks report a WAL read I/O error as NotSupported.
- Round 11 gap (low confidence, pre-existing): the void re-read during recovery can swallow a transient read IOError.
- TSan with the gcc 11 runtime (libtsan.so.0) reports false "double lock of a mutex" on any std::condition_variable::wait_for mutex, upstream TransactionDB code included, because it does not intercept pthread_cond_clockwait. Use clang TSan.
- Round 7 P3: after an open that writes supersession records without a dummy write (for example a WalFilter stop with avoid_flush_during_recovery=true), partition 0's untracked, data-less current WAL carries the supersession record. GetSortedWalFiles skips it, so a GetLiveFiles + GetSortedWalFiles copy could fail with "two live records share index". Checkpoint and BackupEngine are unaffected. Inferred from code, not reproduced.
- Round 2 P3: WriteRecoverableState at N>1 can stamp the cached recoverable state inside an open fence during an auto-resumed retryable WAL error.
- Round 1 P3s: the checkpoint/backup LockWAL race tests can stop on an ASSERT before joining their threads; GC31FollowerExitGroup orders writers with sleeps; standalone db_stress at N>1 trips on the default get_current_wal_file_one_in; checkpoint/backup at N>1 wait out a write stop.
- Gaps: an indexed DB with wal_compression still caches start sequence 1 for a data-less WAL (as upstream does for compression-only WALs); HeadFloor() for a member with no surviving data is the last progress bound read (no production-reachable loss found).

Reports (MetaMate):
- Round 1: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-69c13fcb72e2-20261107t093444z
- Round 2: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold2-2e8c56707a8f-20261107t175411z
- Round 3: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold3-8b6590498-20261107t185930z
- Round 4: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold5-c3c369362-20261107t192653z
- Round 5: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold6-6e3ad3889-20261107t193256z
- Round 6: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold7-376fac935-20261108t054421z
- Round 7: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-fold8-431f2a98e-20261108t055310z
- Round 11: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb2-69a91e9ba-20261110t022328z
- Round 13: https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb8-f6583590ed-20261110t195418z
- Round 15 (final stack): https://metamate.internalmeta.com/artifact/diff-review-pwal-m6-rb15-1686cdb39f-20261111t191953z

Changes visible to existing users:
- Removes DBOptions::experimental_allow_wal_partitions_for_testing, its "experimental_allow_wal_partitions_for_testing" options-string key (which no longer parses) and the C API functions rocksdb_options_set/get_experimental_allow_wal_partitions_for_testing. All were added earlier in this stack (D117251769) and never released.
- The --wal_partitions help text of db_bench and db_stress changed.

Test Plan:
M4 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 4974 tests, 0 failed.

M5 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of compaction_service_test, db_options_test, db_wal_oracle_test, db_wal_partitions_open_test, db_wal_test, db_write_test, latency_injection_fs_test, ldb_cmd_test, optimistic_transaction_test, options_settable_test, transaction_test, write_prepared_transaction_test, db_stress, db_bench, ldb); 7324 tests, 0 failed.

M6 B.1: PASS (debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7340/7340).

Rebased stack (e591f5f): PASS. Debug build and build_tools/gtest-parallel run of compaction_service_test db_options_test db_wal_oracle_test db_wal_partitions_open_test db_wal_test db_write_test latency_injection_fs_test ldb_cmd_test optimistic_transaction_test options_settable_test transaction_test write_prepared_transaction_test: 7559/7559. Full make suite 10540/10540.

Rebased stack (e732049, fbcode/warm 4df7e0a0db7b) final: clang per-diff gates for all 39 diffs; full make suite 10576/10579 at f4c2cc3436 with the 3 round-12 failures fixed at 7fd6043 (transaction_test 3475/3475); clang TSan; crash tests and the two sandcastle repro command lines above. At b19275b: db_write_test under ASAN/UBSAN (clang) 581/581; clang per-diff gates for D121858039 through D123971668 rerun and pass; fbcode/rocks/sandcastle/check-format.sh passes at every diff.
fbcode sandcastle crash tests (blackbox and whitebox; plain, ASAN, TSAN): 6/6 pass on 32fe728cb06b.
Strict status (ASSERT_STATUS_CHECKED=1) suite at f658359: 0 aborts from this stack (27 before the fix).
Rebased stack (facebook/rocksdb eb12834, fbcode/master b1d9881f429e) final: clang per-diff gates for all 39 diffs; full make suite 11192/11192; clang TSan 709/709 once and 2600/2600 at 100x; ASSERT_STATUS_CHECKED with only range_locking_test failing (not touched by this stack); crash tests blackbox and whitebox at wal_partitions 1 and 8 exit 0; `tools/db_crashtest_test.py` 89/89; check-format.sh passes at every diff.

Differential Revision: https://phabricator.intern.facebook.com/D130396596
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant