Skip to content

Add PartitionWALUsage enum and DBOptions plumbing (#15219) - #15219

Open
JustinGaoF wants to merge 1 commit into
meta:mainfrom
JustinGaoF:export-D118367634
Open

JustinGaoF wants to merge 1 commit into
meta:mainfrom
JustinGaoF:export-D118367634

Conversation

@JustinGaoF

@JustinGaoF JustinGaoF commented Sep 16, 2026 •

Copy link
Copy Markdown

Summary:

Defines the PartitionWALUsage enum and plumbs DBOptions::partition_wal_usage through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than kNone prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

  • kNone (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
  • kRecordOrderingSingleFile (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
  • kPartitionByColumnFamily (0x02) -- reserved for partitioning WALs by column family. Not implemented, and DBImpl::ValidateOptions now rejects it with NotSupported in this diff rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. kRecordOrderingSingleFile exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. kPartitionByColumnFamily is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: wal_index stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (kWALIndexSingleFile, kWALIndexPartitionByColumnFamily).

Documentation: the partition_wal_usage field comment and the PartitionWALUsage enum contract disagreed -- the field comment said a non-kNone value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on DBOptions (default kNone) and ImmutableDBOptions, propagation in BuildDBOptions, registration via OptionTypeInfo::Enum against GetPartitionWALUsageStringMap(), the copy constructor, and ROCKS_LOG_HEADER. The string map accepts six keys -- a kFoo and a snake_case spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

BuildDBOptions propagation is easy to miss: partition_wal_usage lives only in ImmutableDBOptions, and options_settable_test, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634

@meta-cla meta-cla Bot added the CLA Signed label Sep 16, 2026
@meta-codesync meta-codesync Bot changed the title Add PartitionWALUsage enum and DBOptions plumbing Add PartitionWALUsage enum and DBOptions plumbing (#15219) Sep 17, 2026
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Sep 17, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers (`wal_index`); no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a `wal_index`, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) — disabled, WAL stays bit-for-bit compatible with older versions.
- `kWALIndexSingleFile` (0x01) — records carry a `wal_index`, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kWALIndexPartitionByColumnFamily` (0x02) — reserved for partitioning WALs by column family. Not implemented; a later diff rejects it at `DB::Open` rather than silently leaving the DB unpartitioned.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys — a `kFoo` and a `snake_case` spelling for each of the three values — so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Sep 17, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers (`wal_index`); no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a `wal_index`, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) — disabled, WAL stays bit-for-bit compatible with older versions.
- `kWALIndexSingleFile` (0x01) — records carry a `wal_index`, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kWALIndexPartitionByColumnFamily` (0x02) — reserved for partitioning WALs by column family. Not implemented; a later diff rejects it at `DB::Open` rather than silently leaving the DB unpartitioned.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys — a `kFoo` and a `snake_case` spelling for each of the three values — so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

✅ clang-tidy: No findings on changed lines

Completed in 291.2s.

JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Sep 17, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers (`wal_index`); no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a `wal_index`, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) — disabled, WAL stays bit-for-bit compatible with older versions.
- `kWALIndexSingleFile` (0x01) — records carry a `wal_index`, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kWALIndexPartitionByColumnFamily` (0x02) — reserved for partitioning WALs by column family. Not implemented; a later diff rejects it at `DB::Open` rather than silently leaving the DB unpartitioned.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys — a `kFoo` and a `snake_case` spelling for each of the three values — so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
@github-actions

github-actions Bot commented Sep 17, 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 b6ce732


Summary

Clean, well-structured option plumbing PR that follows RocksDB conventions. The enum design, option registration, constructor propagation, BuildDBOptions assignment, C API wrappers, and test coverage are all correct. The function-local static for the string map is a nice improvement over the namespace-scope static pattern (CERT ERR58-CPP).

High-severity findings (0):

No high-severity findings.

Full review (click to expand)

Findings

🔴 HIGH

None.

🟡 MEDIUM

M1. Missing RandomInitDBOptions coverage — test_util/testutil.cc
  • Issue: RandomInitDBOptions() does not set partition_wal_usage to a random value. This means the existing DBOptionsComposeImmutable test (which calls RandomInitDBOptions and then verifies round-trip through ImmutableDBOptions -> BuildDBOptions) will always test with the default kNone value for this field.
  • Root cause: The add_option.md checklist does not explicitly mention RandomInitDBOptions, but the existing round-trip tests depend on it for full coverage.
  • Suggested fix: Add to RandomInitDBOptions():
    db_opt->partition_wal_usage =
        static_cast<PartitionWALUsage>(rnd->Uniform(3));
    The dedicated PartitionWALUsageComposeImmutable test mitigates this gap (it explicitly tests all 3 values), so severity is MEDIUM rather than HIGH.
M2. Missing db_stress / db_bench / db_crashtest.py support
  • Issue: Per the add_option.md checklist, new options should have coverage in db_stress_tool/ (DECLARE + DEFINE + apply), tools/db_bench_tool.cc (DEFINE + apply), and tools/db_crashtest.py (randomized values). None of these are present.
  • Root cause: The PR description says this is "API surface" only — no WAL format code yet. The option currently has no runtime effect, so stress/bench integration is arguably premature.
  • Suggested fix: If intentionally deferred, add a TODO comment or mention in the PR description. Alternatively, add a minimal db_stress flag that's a no-op for now, so the infrastructure is ready when behavior is added. At minimum, ensure these are tracked for the follow-up PR that adds runtime behavior.
M3. Missing release note
  • Issue: No file in unreleased_history/new_features/ documents this new option.
  • Root cause: The PR is described as "API surface" only, but it does add a public API that users can set.
  • Suggested fix: Add a brief release note, e.g.:
    Added `DBOptions::partition_wal_usage` option (experimental, `kNone` default, no behavior change yet).

🟢 LOW / NIT

L1. C API setter accepts arbitrary int without validation — db/c.cc
  • Issue: rocksdb_options_set_partition_wal_usage(opt, 42) silently stores an invalid enum value. This is consistent with other C API enum setters (e.g., wal_compression, wal_recovery_mode) which also use unchecked static_cast<decltype(...)>(v), so this follows the existing pattern.
  • Suggested fix: None needed for consistency, but worth noting. Input validation in the C API could be a broader improvement.
L2. Inconsistent string map initialization style — options/db_options.cc
  • Issue: GetPartitionWALUsageStringMap() uses a function-local static (CERT ERR58-CPP compliant), while wal_recovery_mode_string_map and cache_tier_string_map are namespace-scope statics. The function-local pattern is technically better, creating a minor inconsistency.
  • Suggested fix: This is a positive deviation. The PR even includes a comment explaining the rationale. No change needed.
L3. Enum placed before DbPath struct in options.h
  • Issue: The PartitionWALUsage enum is placed between WALRecoveryMode and DbPath, which is a reasonable location near other WAL-related types. However, the corresponding partition_wal_usage field in DBOptions is placed after wal_compression, separated from the enum definition by ~1100 lines.
  • Suggested fix: No change needed — this follows the same pattern as WALRecoveryMode (enum defined near top, field defined in DBOptions struct).

Cross-Component Analysis

Context Affected? Assessment
WritePreparedTxnDB No Pure option plumbing, no runtime behavior
ReadOnly DB No Same
CompactionService No Same
User-defined timestamps No Same
All other contexts No Option has no runtime effect in this PR

Assumption stress test:

  • Claim: "No WAL format code and no on-disk change yet."
    • Verified: No code path reads partition_wal_usage to make runtime decisions. It is only stored, serialized/deserialized, and logged.
    • The OPTIONS file will now contain partition_wal_usage=kNone by default. An older RocksDB version that reads this OPTIONS file will hit an unknown option. However, OptionVerificationType::kNormal is the standard choice, and older versions would only fail if ignore_unknown_options=false (which is the default for strict parsing). This is the expected and correct behavior for new options.

C API duplication analysis:

  • The .inc files and the inlined copies in db/c.cc / include/rocksdb/c.h are the same content — the .inc files are the source, and regen_all.py pastes them into the main files between BEGIN/END markers. The diff correctly updates both. No duplication bug.

Positive Observations

  • The PartitionWALUsageComposeImmutable test explicitly covers all three enum values in a loop — good practice that compensates for the RandomInitDBOptions gap.
  • The PartitionWALUsageFromString test covers all 6 string aliases and includes a negative test ("bogus" → ASSERT_NOK).
  • The function-local static pattern for GetPartitionWALUsageStringMap() is a demonstrable improvement over the legacy namespace-scope pattern.
  • Constructor initializer order in ImmutableDBOptions matches the struct member declaration order (both place partition_wal_usage between wal_compression and background_close_inactive_wals).
  • BuildDBOptions assignment is in the correct position.
  • Struct packing: wal_compression (1 byte) + partition_wal_usage (1 byte) + background_close_inactive_wals (1 byte) pack efficiently with no added padding.

ℹ️ 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

JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Sep 18, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers (`wal_index`); no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a `wal_index`, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) — disabled, WAL stays bit-for-bit compatible with older versions.
- `kWALIndexSingleFile` (0x01) — records carry a `wal_index`, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kWALIndexPartitionByColumnFamily` (0x02) — reserved for partitioning WALs by column family. Not implemented; a later diff rejects it at `DB::Open` rather than silently leaving the DB unpartitioned.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys — a `kFoo` and a `snake_case` spelling for each of the three values — so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Sep 18, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers (`wal_index`); no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a `wal_index`, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) — disabled, WAL stays bit-for-bit compatible with older versions.
- `kWALIndexSingleFile` (0x01) — records carry a `wal_index`, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kWALIndexPartitionByColumnFamily` (0x02) — reserved for partitioning WALs by column family. Not implemented; a later diff rejects it at `DB::Open` rather than silently leaving the DB unpartitioned.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys — a `kFoo` and a `snake_case` spelling for each of the three values — so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Sep 18, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers (`wal_index`); no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a `wal_index`, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) — disabled, WAL stays bit-for-bit compatible with older versions.
- `kWALIndexSingleFile` (0x01) — records carry a `wal_index`, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kWALIndexPartitionByColumnFamily` (0x02) — reserved for partitioning WALs by column family. Not implemented; a later diff rejects it at `DB::Open` rather than silently leaving the DB unpartitioned.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys — a `kFoo` and a `snake_case` spelling for each of the three values — so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Sep 18, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers (`wal_index`); no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a `wal_index`, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) — disabled, WAL stays bit-for-bit compatible with older versions.
- `kWALIndexSingleFile` (0x01) — records carry a `wal_index`, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kWALIndexPartitionByColumnFamily` (0x02) — reserved for partitioning WALs by column family. Not implemented; a later diff rejects it at `DB::Open` rather than silently leaving the DB unpartitioned.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys — a `kFoo` and a `snake_case` spelling for each of the three values — so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Sep 18, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers (`wal_index`); no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a `wal_index`, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) — disabled, WAL stays bit-for-bit compatible with older versions.
- `kWALIndexSingleFile` (0x01) — records carry a `wal_index`, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kWALIndexPartitionByColumnFamily` (0x02) — reserved for partitioning WALs by column family. Not implemented; a later diff rejects it at `DB::Open` rather than silently leaving the DB unpartitioned.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys — a `kFoo` and a `snake_case` spelling for each of the three values — so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Sep 18, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers (`wal_index`); no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a `wal_index`, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) — disabled, WAL stays bit-for-bit compatible with older versions.
- `kWALIndexSingleFile` (0x01) — records carry a `wal_index`, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kWALIndexPartitionByColumnFamily` (0x02) — reserved for partitioning WALs by column family. Not implemented; a later diff rejects it at `DB::Open` rather than silently leaving the DB unpartitioned.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys — a `kFoo` and a `snake_case` spelling for each of the three values — so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Sep 18, 2026
Summary:
Pull Request resolved: meta#15219

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers (`wal_index`); no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a `wal_index`, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) — disabled, WAL stays bit-for-bit compatible with older versions.
- `kWALIndexSingleFile` (0x01) — records carry a `wal_index`, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kWALIndexPartitionByColumnFamily` (0x02) — reserved for partitioning WALs by column family. Not implemented; a later diff rejects it at `DB::Open` rather than silently leaving the DB unpartitioned.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys — a `kFoo` and a `snake_case` spelling for each of the three values — so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
@meta-codesync

meta-codesync Bot commented Sep 18, 2026

Copy link
Copy Markdown

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

JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Sep 18, 2026
Summary:
Pull Request resolved: meta#15219

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers (`wal_index`); no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a `wal_index`, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) — disabled, WAL stays bit-for-bit compatible with older versions.
- `kWALIndexSingleFile` (0x01) — records carry a `wal_index`, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kWALIndexPartitionByColumnFamily` (0x02) — reserved for partitioning WALs by column family. Not implemented; a later diff rejects it at `DB::Open` rather than silently leaving the DB unpartitioned.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys — a `kFoo` and a `snake_case` spelling for each of the three values — so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
@github-actions

github-actions Bot commented Sep 18, 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 bc52331


Summary

Clean, well-structured option plumbing PR. The enum definition, ImmutableDBOptions wiring, OptionTypeInfo registration, BuildDBOptions propagation, and tests are all correctly implemented. The main gaps are missing items from the add_option checklist (db_stress, db_bench, db_crashtest, release notes) and a style inconsistency in the string map pattern.

High-severity findings (0):

No high-severity findings.

Full review (click to expand)

Findings

🔴 HIGH

None.

🟡 MEDIUM

M1. Missing checklist items per claude_md/add_option.md -- multiple files
  • Issue: The add_option checklist requires db_stress support (db_stress_common.h DECLARE, db_stress_gflags.cc DEFINE, db_stress_test_base.cc apply), db_bench support (db_bench_tool.cc), crash test support (db_crashtest.py), and a release note in unreleased_history/. None of these are present.
  • Root cause: The PR description says this is "API surface" only, but the checklist items ensure the option is exercisable in testing infrastructure from the start.
  • Suggested fix: Add the missing plumbing, or document explicitly in the PR description that these will follow in a subsequent diff. At minimum, add a release note file in unreleased_history/new_features/ or unreleased_history/public_api_changes/. For db_stress/db_bench, if deferred, consider adding a // TODO or tracking issue.
M2. No DB::Open validation rejects unimplemented kWALIndexPartitionByColumnFamily -- db/db_impl/db_impl_open.cc
  • Issue: kWALIndexPartitionByColumnFamily is explicitly documented as "NOT YET IMPLEMENTED" but can be set without error. The PR description says "a later diff rejects it at DB::Open" but that diff is not included. Until it lands, a user can set this value and get no error, no partitioning, and potentially confusing behavior when the WAL format code eventually lands.
  • Root cause: Intentional staging of the implementation across multiple diffs.
  • Suggested fix: Either include the DB::Open rejection in this PR (a ~5-line addition to DBImpl::ValidateOptions), or ensure the follow-up diff is tightly coupled and lands together. The safest approach is to add the validation now:
    if (db_options.partition_wal_usage == PartitionWALUsage::kWALIndexPartitionByColumnFamily) {
      return Status::NotSupported("kWALIndexPartitionByColumnFamily is not yet implemented");
    }
M3. RandomInitDBOptions not updated -- test_util/testutil.cc:302
  • Issue: RandomInitDBOptions does not randomize partition_wal_usage. This means the existing DBOptionsComposeImmutable and DBOptionsSerialization round-trip tests (which call RandomInitDBOptions) won't exercise the new field. The PR adds a dedicated PartitionWALUsageComposeImmutable test to compensate, but the gap in RandomInitDBOptions means future tests relying on it also won't cover this field.
  • Root cause: RandomInitDBOptions has fallen behind on newer fields (e.g., wal_compression is also missing).
  • Suggested fix: Add db_opt->partition_wal_usage = static_cast<PartitionWALUsage>(rnd->Uniform(3)); to RandomInitDBOptions. This is a pre-existing gap but the PR should not widen it.

🟢 LOW / NIT

L1. Inconsistent string map pattern -- options/db_options.cc:38-52
  • Issue: The PR introduces GetPartitionWALUsageStringMap() as a function-local static with a CERT ERR58-CPP comment, while all existing maps (wal_recovery_mode_string_map, cache_tier_string_map, info_log_level_string_map) are namespace-scope statics. The CERT concern is technically valid (dynamic initialization of globals can throw before main()), but applying it to only one map creates inconsistency.
  • Suggested fix: Either apply the pattern consistently (refactor existing maps too -- probably out of scope for this PR) or use the existing namespace-scope pattern for consistency. If keeping the function-local pattern, consider dropping the lengthy comment and just using the pattern silently, or adding a brief // Function-local static for safe initialization one-liner.
L2. Dual naming in string map (kFoo + snake_case) -- options/db_options.cc
  • Issue: The map has 6 entries for 3 values, providing both kFoo and snake_case spellings. Existing maps (wal_recovery_mode_string_map, cache_tier_string_map) only provide kFoo spellings. The extra flexibility is user-friendly but deviates from the pattern.
  • Suggested fix: This is arguably an improvement. Acceptable if the team agrees on the precedent.
L3. C API roundtrip test only exercises values 0 and 1 -- c_api_gen/c_generated_roundtrip_tests.c.inc
  • Issue: The auto-generated roundtrip test sets values 0 and 1 but doesn't test value 2 (kWALIndexPartitionByColumnFamily). This is a limitation of the auto-generator, not the PR itself.
  • Suggested fix: No action needed for this PR -- this is an auto-generator limitation.
L4. Dump() could use string name instead of int -- options/db_options.cc
  • Issue: ROCKS_LOG_HEADER(log, "Options.partition_wal_usage: %d", static_cast<int>(partition_wal_usage)) logs the raw integer. Other options like wal_recovery_mode also log as %d, so this is consistent, but for a new enum, logging the string name (e.g., "kWALIndexSingleFile") would be more user-friendly.
  • Suggested fix: Optional improvement for readability. Current approach is consistent with existing patterns.

Cross-Component Analysis

Context Does code execute? Assumptions hold? Action needed?
WritePreparedTxnDB N/A (option not consumed) N/A None
ReadOnly DB N/A N/A None
CompactionService N/A N/A None
User-defined timestamps N/A N/A None
OPTIONS file serialization YES - via OptionTypeInfo YES Older binaries will fail to parse unknown enum string (safe)
C API YES - set/get plumbed Mostly - no input validation on int range Acceptable (consistent with existing pattern)

Positive Observations

  • The PartitionWALUsageComposeImmutable test explicitly addresses the gap left by options_settable_test being compiled out under clang. This is thoughtful engineering.
  • The PartitionWALUsageFromString test comprehensively covers all 6 string variants plus a negative case.
  • The enum documentation includes clear rollback instructions, which is good practice for on-disk format changes.
  • The C API is correctly auto-generated via auto_simple_bindings.py rather than hand-written.
  • Constructor initialization order in ImmutableDBOptions matches declaration order -- verified correct.

ℹ️ 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

JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Sep 24, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
@github-actions

github-actions Bot commented Sep 24, 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 5299669


Summary

Clean, well-structured options plumbing PR. The enum design, validation approach, and test coverage are solid. The change correctly follows existing patterns for adding an immutable DB option with C API support.

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

Full review (click to expand)

Findings

🔴 HIGH

None.

🟡 MEDIUM

M1. RandomInitDBOptions not updated — test_util/testutil.cc
  • Issue: RandomInitDBOptions() does not randomize partition_wal_usage. This function is used by multiple round-trip serialization tests (DBOptionsSerialization, DBOptionsComposeImmutable, OptionsFileParser, etc.). Those tests will always use the default kNone for this field, so they won't catch a serialization or compose bug for non-default values.
  • Root cause: The new option was not added to the randomization function.
  • Mitigating factor: The PR adds a dedicated PartitionWALUsageComposeImmutable test that explicitly round-trips all three enum values, and PartitionWALUsageFromString tests all six string spellings. Additionally, options_settable_test uses kRecordOrderingSingleFile, which validates the non-default path. Other enum options (wal_recovery_mode, wal_compression) are also not randomized in this function, so the omission is consistent with the existing pattern — but it would be better practice to add it.
  • Suggested fix: Add db_opt->partition_wal_usage = static_cast<PartitionWALUsage>(rnd->Uniform(2)); (only values 0-1 since value 2 is rejected by ValidateOptions) to RandomInitDBOptions in test_util/testutil.cc. Or keep it consistent with existing enum options and skip.
M2. C API lacks input validation for out-of-range values
  • Issue: rocksdb_options_set_partition_wal_usage uses static_cast<decltype(...)>(v) which accepts any integer, including values outside the 0-2 range. Passing, e.g., 99 would set an invalid enum value, and behavior would be undefined when the option is later inspected.
  • Root cause: This matches the existing pattern for all other C API enum setters (wal_compression, wal_recovery_mode, etc.) — none validate input ranges. So this is not a regression.
  • Mitigating factor: This is a pre-existing pattern across all C API enum setters. Fixing it here alone would be inconsistent.
  • Suggested fix: No action needed for this PR. This could be addressed as a separate, codebase-wide improvement to the C API enum setters.

🟢 LOW / NIT

L1. HISTORY.md not updated
  • Issue: No release notes entry for the new PartitionWALUsage option. Per CLAUDE.md, release notes should be kept short for external user consumption.
  • Mitigating factor: The option is marked EXPERIMENTAL and has no on-disk effect yet (kNone is the only usable non-rejected value besides kRecordOrderingSingleFile, and neither does anything yet). Adding release notes when the implementation lands may be more appropriate.
  • Suggested fix: Consider adding a one-liner to HISTORY.md under the current release section, e.g., "Add experimental partition_wal_usage option to DBOptions (no behavioral change yet)."
L2. String map uses function-local static (improvement over convention)
  • Issue: GetPartitionWALUsageStringMap() uses a function-local static with CERT ERR58-CPP justification, while existing maps (wal_recovery_mode_string_map, cache_tier_string_map) use namespace-scope statics. This is a strictly better pattern.
  • Suggested fix: Not an issue — this is positive. Consider refactoring existing maps to follow this pattern in a future cleanup PR.
L3. static_cast used in C API code
  • Issue: CLAUDE.md says "Avoid static_cast [...] static_cast_with_check, up_cast, and lossless_cast from cast_util.h are preferred." However, the C API consistently uses static_cast for int-to-enum and enum-to-int conversions. static_cast_with_check (which uses dynamic_cast in debug) doesn't apply to enum casts, and lossless_cast is for numeric type conversions.
  • Mitigating factor: All existing C API enum setters use this exact pattern. The cast is between int and a char-based enum, which is well-defined.
  • Suggested fix: No action needed. The CLAUDE.md guidance about avoiding static_cast applies to pointer casts (class hierarchy), not to enum/integer conversions.
L4. db/c_test.c not updated
  • Issue: The manual C API test file (db/c_test.c) tests wal_compression getter/setter at line 3918 but does not test partition_wal_usage.
  • Mitigating factor: The auto-generated roundtrip test (c_generated_roundtrip_tests.c.inc) covers set/get with values 0 and 1, which provides equivalent coverage.
  • Suggested fix: Optional: add a manual test for consistency. Not required since the generated test covers it.

Cross-Component Analysis

Context Relevant? Analysis
WritePreparedTxnDB No Option is not read by any runtime code yet
ReadOnly DB No Same reason
Compaction No Same reason
User-defined timestamps No Same reason
OPTIONS file persistence Yes Correctly handled via OptionTypeInfo::Enum registration
C API consumers Yes Correctly handled with getter/setter
Java/JNI bindings No Neither wal_compression nor neighboring options have Java bindings

This is an API-only plumbing PR with no runtime behavioral change. The cross-component risk is minimal — the option is declared, serialized, and validated, but not consumed by any execution path.

Positive Observations

  1. Defensive validation: Rejecting kPartitionByColumnFamily at DB::Open rather than silently ignoring it is the right approach. This prevents configurations that promise partitioning but don't deliver it.
  2. Dual string spellings: The string map accepts both kFoo and snake_case for each value, which is user-friendly for OPTIONS files and CLI tools.
  3. CERT ERR58-CPP compliance: The function-local static pattern for the string map is safer than the namespace-scope pattern used by existing maps.
  4. Comprehensive tests: The PR tests the full compose/immutable round-trip, all string spellings, invalid strings, and the Open validation for all three enum values.
  5. Clean scope: The PR is correctly scoped to API surface only, with no premature implementation code.
  6. Good documentation: The enum comments clearly explain the EXPERIMENTAL nature, rollback procedure, and the relationship between values.

ℹ️ 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

JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 1, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 1, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 1, 2026
Summary:
Pull Request resolved: meta#15219

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 1, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
@github-actions

github-actions Bot commented Oct 1, 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 c2a968e


Summary

This PR adds the PartitionWALUsage enum and plumbs DBOptions::partition_wal_usage through the options machinery. The options plumbing is correctly done following established patterns. However, the PR description claims ValidateOptions rejects kPartitionByColumnFamily, but no such validation exists in the diff, and the test contradicts the claim by expecting ASSERT_OK for that value. Several items from the add_option checklist are missing (RandomInitDBOptions, db_stress, db_bench, crashtest, release notes).

High-severity findings (2):

  • [db/db_impl/db_impl_open.cc] Missing ValidateOptions rejection of kPartitionByColumnFamily -- the PR description explicitly states this validation is "in this diff" but it is not.
  • [db/db_wal_test.cc:3585] Test PartitionWALUsageOpenValidation expects ASSERT_OK for kPartitionByColumnFamily, contradicting the stated design that this value should be rejected until implemented.
Full review (click to expand)

Findings

🔴 HIGH

H1. Missing ValidateOptions rejection of kPartitionByColumnFamily -- db/db_impl/db_impl_open.cc
  • Issue: The PR description explicitly states: "DBImpl::ValidateOptions now rejects it with NotSupported in this diff rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor." However, DBImpl::ValidateOptions(const DBOptions&) at db/db_impl/db_impl_open.cc:245-327 contains no mention of partition_wal_usage. The validation code is entirely absent from the diff.
  • Root cause: The validation was described in the PR summary but not implemented (or was accidentally omitted from the diff).
  • Suggested fix: Add to DBImpl::ValidateOptions(const DBOptions&):
    if (db_options.partition_wal_usage == PartitionWALUsage::kPartitionByColumnFamily) {
      return Status::NotSupported(
          "PartitionWALUsage::kPartitionByColumnFamily is not yet implemented");
    }
H2. Test expects OK for a value that should be rejected -- db/db_wal_test.cc:3585
  • Issue: PartitionWALUsageOpenValidation iterates over both kNone and kPartitionByColumnFamily and calls ASSERT_OK(TryReopen(options)) for both. If the ValidateOptions rejection from H1 were added, this test would fail on kPartitionByColumnFamily. The test should instead use ASSERT_NOK or ASSERT_TRUE(s.IsNotSupported()) for the unimplemented value.
  • Root cause: Either the test was written before the design decision to reject kPartitionByColumnFamily, or the validation was accidentally dropped.
  • Suggested fix: Split the test into two cases -- one that expects OK for kNone, and one that expects NotSupported for kPartitionByColumnFamily.

🟡 MEDIUM

M1. Missing RandomInitDBOptions update -- test_util/testutil.cc:302
  • Issue: RandomInitDBOptions() does not set partition_wal_usage to a random value. This function is used by DBOptionsComposeImmutable and similar round-trip tests to verify that all fields survive the DBOptions -> ImmutableDBOptions -> BuildDBOptions -> DBOptions round trip. A missing field here means the round trip for partition_wal_usage is only tested by the dedicated PartitionWALUsageComposeImmutable test, not by the generic randomized test.
  • Suggested fix: Add db_opt->partition_wal_usage = rnd->Uniform(2) ? PartitionWALUsage::kPartitionByColumnFamily : PartitionWALUsage::kNone; (or only use kNone if validation rejects other values during round-trip testing).
M2. Missing db_stress / db_bench / crashtest support
  • Issue: Per claude_md/add_option.md, new options should have db_stress_common.h DECLARE, db_stress_gflags.cc DEFINE, db_stress_test_base.cc application, db_bench_tool.cc flag, and db_crashtest.py randomization. None of these are present. For an EXPERIMENTAL option this may be intentionally deferred, but it should be explicitly stated.
  • Suggested fix: Either add stress/bench support or document deferral in the PR description.
M3. Missing release note
  • Issue: No file under unreleased_history/new_features/ or unreleased_history/public_api_changes/ for this new option/enum. Per the add_option checklist, a release note markdown file is expected.
  • Suggested fix: Add e.g. unreleased_history/new_features/partition_wal_usage.md with a one-line description.
M4. Enum gap at 0x01 -- undefined value risk
  • Issue: The enum defines kNone = 0x00 and kPartitionByColumnFamily = 0x02, leaving 0x01 undefined. The C API setter performs static_cast<PartitionWALUsage>(v) without range checking, so a C caller passing 1 would create an instance with an undefined enum value. While this matches the existing pattern for other enum C API options (no validation), the intentional gap makes it more likely to be triggered accidentally.
  • Root cause: kRecordOrderingSingleFile = 0x01 was removed from the enum but its slot was preserved for future use.
  • Suggested fix: This is acceptable if the intent is to reserve the slot, but a comment in the enum noting "0x01 reserved for future use" would prevent confusion. Alternatively, renumber kPartitionByColumnFamily to 0x01.

🟢 LOW / NIT

L1. Enum documentation mentions "marker record" not in this diff
  • Issue: The enum header comment says "tags the file with an identifying marker record" for non-kNone values, but this diff contains no marker record implementation. While acceptable for a plumbing-only PR, the comment describes future behavior as present tense.
  • Suggested fix: Change "tags the file" to "will tag the file" or add "(not yet implemented)" to clarify this is describing the intended contract.
L2. options_settable_test uses kPartitionByColumnFamily which should be rejected
  • Issue: options_settable_test.cc sets partition_wal_usage=kPartitionByColumnFamily; in the test string. If ValidateOptions rejects this value, this test string may need to use kNone instead (the settable test verifies serialization round-trip, not DB open, so it may still work, but it's misleading).
  • Suggested fix: Consider using kNone in the settable test string if kPartitionByColumnFamily is meant to be rejected at open time.
L3. CERT ERR58-CPP comment is unnecessarily specific
  • Issue: The comment on GetPartitionWALUsageStringMap() explains CERT ERR58-CPP motivation. The existing wal_recovery_mode_string_map and cache_tier_string_map are namespace-scope statics without this pattern. Applying the pattern to only the new map is inconsistent. The comment is correct but the inconsistency is a nit.
  • Suggested fix: Either apply construct-on-first-use to all similar maps (separate cleanup PR) or just add the new map in the same style as existing ones for consistency. If the team prefers the safer pattern going forward, note that in the PR description.
L4. kPartitionByColumnFamily documentation says "not implemented yet"
  • Issue: The enum member comment says "Column-family routing is not implemented yet: until it is, all column families share one WAL at a time, as with kNone." This accurately describes the current state, but combined with the missing ValidateOptions rejection, it means the option can be set and will be silently identical to kNone -- which is exactly what the PR description says should NOT happen.

Cross-Component Analysis

Context Affected? Notes
WritePreparedTxnDB No Option is plumbing-only, no behavioral change yet
ReadOnly DB No Options are parsed but WAL behavior not changed
CompactionService No No compaction interaction
User-defined timestamps No No key format interaction
Snapshots No No visibility change
All execution contexts Safe This is pure options plumbing with no runtime behavior change

Positive Observations

  • The options plumbing follows established patterns correctly (ImmutableDBOptions, BuildDBOptions, Dump, OptionTypeInfo::Enum, settable test).
  • The construct-on-first-use pattern for the string map is technically superior to the existing namespace-scope static pattern (CERT ERR58-CPP compliance).
  • The PartitionWALUsageFromString test is thorough -- it tests both kFoo and snake_case spellings, and explicitly verifies that removed values (kRecordOrderingSingleFile) no longer parse.
  • The PartitionWALUsageComposeImmutable test provides good coverage for the BuildDBOptions round trip, compensating for the known gap that options_settable_test is compiled out under clang.
  • String map provides both kFoo and snake_case spellings for each value, matching the convention used by other enum options.

ℹ️ 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

JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 1, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 1, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 1, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 1, 2026
Summary:
Pull Request resolved: meta#15219

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 1, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 1, 2026
Summary:
Pull Request resolved: meta#15219

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
@github-actions

github-actions Bot commented Oct 1, 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 db4869d


Summary

Options plumbing is well-structured and follows existing conventions. The main issues are: (1) missing ValidateOptions rejection of kPartitionByColumnFamily that the PR description promises, (2) the test asserting OK for the value that should be rejected, (3) missing checklist items (db_stress, db_bench, db_crashtest.py, release note), and (4) the C API roundtrip test exercising an invalid enum value.

High-severity findings (2):

  • [db/db_impl/db_impl_open.cc + db/db_wal_test.cc] Missing ValidateOptions rejection of kPartitionByColumnFamily contradicts PR description; test asserts OK for a value the description says must be rejected.
  • [c_api_gen/c_generated_roundtrip_tests.c.inc] Auto-generated C API roundtrip test exercises enum value 1 (the skipped slot), validating an invalid enum value.
Full review (click to expand)

Findings

🔴 HIGH

H1. Missing ValidateOptions rejection of kPartitionByColumnFamily — db/db_impl/db_impl_open.cc
  • Issue: The PR description explicitly states: "DBImpl::ValidateOptions now rejects it with NotSupported in this diff rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor." However, the diff adds NO validation code to DBImpl::ValidateOptions in db/db_impl/db_impl_open.cc:245. The PartitionWALUsageOpenValidation test in db/db_wal_test.cc:3582 asserts ASSERT_OK(TryReopen(options)) for kPartitionByColumnFamily, confirming the rejection is missing.
  • Root cause: The validation was described in the PR summary but not implemented in the diff.
  • Suggested fix: Add to DBImpl::ValidateOptions(const DBOptions&):
    if (db_options.partition_wal_usage ==
        PartitionWALUsage::kPartitionByColumnFamily) {
      return Status::NotSupported(
          "partition_wal_usage=kPartitionByColumnFamily is not yet implemented");
    }
    And update the test to ASSERT_TRUE(TryReopen(options).IsNotSupported()) for kPartitionByColumnFamily.
H2. C API roundtrip test validates invalid enum value — c_api_gen/c_generated_roundtrip_tests.c.inc
  • Issue: The auto-generated roundtrip test does rocksdb_options_set_partition_wal_usage(obj, 1) and checks it reads back as 1. But enum value 1 (kRecordOrderingSingleFile) was intentionally removed from the enum. The test exercises and validates storing an invalid enum value. This happens because the auto-generator uses simple 0/1 toggle tests.
  • Root cause: The auto-generator always tests with values 0 and 1. Since kNone=0x00 and kPartitionByColumnFamily=0x02, value 1 is a hole in the enum.
  • Suggested fix: Either (a) add the roundtrip test to a blocklist override so it uses values 0 and 2, or (b) accept this as a known limitation of the auto-generator (the C API has no bounds checking by convention).

🟡 MEDIUM

M1. Missing db_stress/db_bench/db_crashtest.py/release note — per claude_md/add_option.md
  • Issue: The add_option.md checklist requires db_stress support (DECLARE/DEFINE in db_stress_common.h, db_stress_gflags.cc, db_stress_test_base.cc), db_bench support (tools/db_bench_tool.cc), db_crashtest.py randomized values, and an unreleased_history entry. None are present.
  • Suggested fix: This may be intentional for a plumbing-only PR where the feature does nothing yet. If so, document that these will come in a follow-up. Otherwise, add them.
M2. PR description/code mismatch on string map key count
  • Issue: The PR description says "The string map accepts six keys -- a kFoo and a snake_case spelling for each of the three values." But the code only has 4 keys (for 2 values). The PR description appears stale — it describes the version with kRecordOrderingSingleFile still present.
  • Suggested fix: Update the PR description to say 4 keys for 2 values.
M3. Enum value gap at 0x01 lacks documentation
  • Issue: PartitionWALUsage has kNone=0x00 and kPartitionByColumnFamily=0x02, skipping 0x01. There's no comment explaining the gap or reserving 0x01. If someone constructs value 0x01 via the C API or deserialization, behavior is undefined.
  • Suggested fix: Add a comment: // 0x01 is reserved for future use.

🟢 LOW / NIT

L1. Enum comment mentions "marker record" not in this diff
  • Issue: The enum header comment says "tags the file with an identifying marker record" — but this is a plumbing-only PR with no on-disk changes. The comment describes future behavior that doesn't exist yet.
  • Suggested fix: Clarify that these are planned behaviors, or defer the comment to the implementation PR.
L2. CERT ERR58-CPP comment on GetPartitionWALUsageStringMap is good but inconsistent
  • Issue: The new GetPartitionWALUsageStringMap() uses function-local static (CERT ERR58-CPP compliant), with a detailed comment explaining why. But the existing wal_recovery_mode_string_map and cache_tier_string_map at the top of the same file use namespace-scope statics. The inconsistency is fine (the new code is better), but the comment could be shorter.
  • Suggested fix: No action needed — the new pattern is an improvement.
L3. ImmutableDBOptions struct field ordering is reasonable
  • Issue: PartitionWALUsage partition_wal_usage (char-sized) is placed between CompressionType wal_compression (char) and bool background_close_inactive_wals (1 byte). Three consecutive 1-byte fields pack efficiently.
  • Suggested fix: None needed.

Cross-Component Analysis

Context Affected? Notes
WritePreparedTxnDB No Plumbing only, no runtime behavior
ReadOnly DB No Option is read during Open only
CompactionService No WAL option, not compaction
User-defined timestamps No Orthogonal feature
Serialization (OPTIONS file) Yes OptionTypeInfo registration covers this; string parsing tested
C API Yes Auto-generated wrappers work correctly; roundtrip test has H2 issue

Positive Observations

  • Clean separation of enum definition and option plumbing
  • Function-local static for string map is a good practice (CERT ERR58-CPP)
  • Comprehensive string parsing tests covering both kFoo and snake_case names, plus rejection of removed/invalid names
  • PartitionWALUsageComposeImmutable test explicitly tests the ImmutableDBOptions round-trip, catching the gap that options_settable_test misses under clang
  • BuildDBOptions propagation is present and tested

ℹ️ 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

JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 2, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 2, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 2, 2026
Summary:
Pull Request resolved: meta#15219

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 2, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 2, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 2, 2026
Summary:
Pull Request resolved: meta#15219

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

✅ Claude Code Review

Auto-triggered after CI passed — reviewing commit 8df0f07


Summary

API-plumbing-only diff for a new PartitionWALUsage enum and DBOptions::partition_wal_usage field. The options machinery wiring (ImmutableDBOptions, BuildDBOptions, OptionTypeInfo, Dump, C API, settable test) is correct and complete. The main concern is a contradiction between the PR description and the actual code regarding validation of kPartitionByColumnFamily.

High-severity findings (1):

  • [db/db_wal_test.cc / db_impl_open.cc] PR description claims ValidateOptions rejects kPartitionByColumnFamily with NotSupported "in this diff," but no such validation exists in the diff or codebase, and the test ASSERT_OKs opening with that value.
Full review (click to expand)

Findings

🔴 HIGH

H1. Missing ValidateOptions rejection contradicts PR description -- db/db_impl/db_impl_open.cc
  • Issue: The PR description states: "DBImpl::ValidateOptions now rejects it with NotSupported in this diff rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor." However, DBImpl::ValidateOptions(const DBOptions&) at db/db_impl/db_impl_open.cc:245-326 contains no check for partition_wal_usage, and the diff does not add one. The test PartitionWALUsageOpenValidation in db/db_wal_test.cc confirms this by calling ASSERT_OK(TryReopen(options)) for kPartitionByColumnFamily.
  • Root cause: Either the validation code was accidentally omitted from the diff, or the PR description is stale/misleading and validation was deferred.
  • Impact: If kPartitionByColumnFamily is accepted but has no implementation, users could set it and get silently wrong behavior (no actual partitioning). The PR description's stated invariant -- "no revision of the tree ever accepts an option value it cannot honor" -- is violated.
  • Suggested fix: Add to DBImpl::ValidateOptions(const DBOptions&):
    if (db_options.partition_wal_usage ==
        PartitionWALUsage::kPartitionByColumnFamily) {
      return Status::NotSupported(
          "PartitionWALUsage::kPartitionByColumnFamily is not yet implemented");
    }
    And change the test to ASSERT_NOK for kPartitionByColumnFamily, or split the test to verify that kNone succeeds and kPartitionByColumnFamily is rejected. If validation is intentionally deferred, update the PR description to remove the claim.

🟡 MEDIUM

M1. Missing db_stress / db_bench / crashtest support
  • Issue: Per claude_md/add_option.md, new options should be wired into db_stress_tool (DECLARE/DEFINE/apply), tools/db_bench_tool.cc, and tools/db_crashtest.py. None of these are present.
  • Suggested fix: This may be intentionally deferred since the feature is not yet functional. If so, add a tracking comment or issue. If the option is meant to be testable now (at least kNone), add the plumbing.
M2. Missing release note
  • Issue: No file in unreleased_history/ documents this new public API addition.
  • Suggested fix: Add unreleased_history/new_features/partition_wal_usage.md or unreleased_history/public_api_changes/partition_wal_usage.md with a short description.

🟢 LOW / NIT

L1. Enum value gap (0x01) undocumented in code -- include/rocksdb/options.h
  • Issue: The enum jumps from kNone = 0x00 to kPartitionByColumnFamily = 0x02, reserving 0x01 for the removed kRecordOrderingSingleFile. While the PR description explains this, there is no code comment explaining why 0x01 is skipped, which will confuse future readers.
  • Suggested fix: Add a comment like // 0x01 reserved for future kRecordOrderingSingleFile or simply use sequential values if the reservation is not needed.
L2. Inconsistent string map pattern -- options/db_options.cc
  • Issue: GetPartitionWALUsageStringMap() uses a function-local static (CERT ERR58-CPP compliant), while existing maps like wal_recovery_mode_string_map and cache_tier_string_map use namespace-scope statics. The new pattern is technically better but inconsistent.
  • Suggested fix: This is fine as-is and could serve as a template for migrating existing maps. No change needed, but consider a follow-up to unify patterns.
L3. C API setter accepts arbitrary int values -- db/c.cc
  • Issue: rocksdb_options_set_partition_wal_usage casts any int to the enum type without bounds checking. An invalid value like 42 would be silently accepted.
  • Suggested fix: This matches the existing pattern for all other enum C API setters (wal_recovery_mode, wal_compression, etc.), so no change is strictly needed for consistency. A codebase-wide improvement to add bounds checking would be a separate effort.
L4. PR description mentions six string map keys, but only four exist
  • Issue: The PR description says "The string map accepts six keys -- a kFoo and a snake_case spelling for each of the three values." But only two values exist in the enum now (kNone and kPartitionByColumnFamily), yielding four keys, not six.
  • Suggested fix: Update the PR description to match reality (four keys for two values).

Cross-Component Analysis

Context Does code execute? Assumptions hold? Action needed?
WritePreparedTxnDB N/A (option only) YES None
ReadOnly DB N/A (option only) YES None
SecondaryInstance N/A (option only) YES None
CompactionService N/A (option only) YES None
User-defined timestamps N/A (option only) YES None

This is a pure options-plumbing diff with no runtime behavior changes, so cross-component impact is minimal. The only risk is the missing validation (H1) allowing users to set an unimplemented value.

Positive Observations

  • The PartitionWALUsage enum uses enum class (scoped enum) as recommended by RocksDB style.
  • The CERT ERR58-CPP-compliant function-local static pattern is a good practice that improves on existing code.
  • The PartitionWALUsageFromString test explicitly verifies that removed enum value names are rejected.
  • The PartitionWALUsageComposeImmutable test correctly verifies the full round-trip through ImmutableDBOptions and BuildDBOptions, which is important since options_settable_test is compiled out under clang.
  • The auto-generated C API code is properly regenerated via auto_simple_bindings.py with PartitionWALUsage added to enum_types.

ℹ️ 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

JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 7, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 7, 2026
Summary:
Pull Request resolved: meta#15219

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 7, 2026
Summary:

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
Summary:
Pull Request resolved: meta#15219

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Oct 20, 2026
Summary:
Pull Request resolved: meta#15219

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has three values. Every value other than `kNone` prefixes each WAL record with a persisted monotonically increasing ordering number, so they share one on-disk format change and differ only in WAL layout:

- `kNone` (0x00) -- disabled, WAL stays bit-for-bit compatible with older versions.
- `kRecordOrderingSingleFile` (0x01) -- records carry an ordering number, WAL layout unchanged. Isolates the format change from any routing change so the two roll out separately.
- `kPartitionByColumnFamily` (0x02) -- reserved for partitioning WALs by column family. Not implemented, and `DBImpl::ValidateOptions` now rejects it with `NotSupported` **in this diff** rather than in a later one, so no revision of the tree ever accepts an option value it cannot honor. Without that, the value would be accepted and inert here, and once the writer diffs land it would silently mean "ordering numbers, no partitioning".

Why three values rather than a boolean: they are a rollout ladder, not a taxonomy. `kRecordOrderingSingleFile` exists to be the middle rung -- it turns on the persisted on-disk format change while leaving WAL routing untouched, so the format can bake in production before any routing behavior changes. A boolean cannot express that: "partitioned or not" forces the format change and the routing change to ship as one flip, which is precisely the rollout risk the middle rung removes. `kPartitionByColumnFamily` is the top rung, and rejecting it until it works keeps the ladder from ever exposing a rung that is accepted but inert.

The value names describe observable behavior rather than the mechanism: `wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format, but it no longer appears in the public enum. Nothing has shipped, so there are no compatibility aliases for the previous spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`).

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts six keys -- a `kFoo` and a `snake_case` spelling for each of the three values -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

Differential Revision: D118367634
JustinGaoF added a commit to JustinGaoF/rocksdb that referenced this pull request Nov 19, 2026
Summary:
Pull Request resolved: meta#15219

Defines the `PartitionWALUsage` enum and plumbs `DBOptions::partition_wal_usage` through the options machinery. This is the API surface for per-record WAL ordering numbers; no WAL format code and no on-disk change yet.

The enum has two values:

- `kNone` (0x00) -- disabled. The WAL stays bit-for-bit compatible with older versions.
- `kPartitionByColumnFamily` (0x02) -- every WAL record carries a persisted, monotonically increasing ordering number, and every WAL file starts with a marker record. This is the on-disk format change. With `wal_partitions=1` (the default) it changes only the WAL format: one WAL file is written at a time, as today.

How many WAL files are written at a time is a separate option, `DBOptions::wal_partitions`, added later in this stack (D117251769). `wal_partitions > 1` is rejected at `DB::Open` with `NotSupported` until the partitioned write path is complete; the only exception is the testing opt-in `experimental_allow_wal_partitions_for_testing`. No revision of the stack rejects `kPartitionByColumnFamily` on its own, and `DBWALTest.PartitionWALUsageOpenValidation` pins that Open accepts both values here.

An earlier revision had a third value, `kRecordOrderingSingleFile` (0x01), for "format change without partitioning". It was removed because the routing mode moved to `wal_partitions`: `kPartitionByColumnFamily` with `wal_partitions=1` is that state. 0x01 is not reused. The format change and the routing change can still roll out separately, through the two options.

`wal_index` stays the internal term for the ordering number, in implementation code and in the WAL record format; it does not appear in the public enum. Nothing has shipped, so there are no compatibility aliases for earlier spellings (`kWALIndexSingleFile`, `kWALIndexPartitionByColumnFamily`, `kRecordOrderingSingleFile`); they no longer parse.

Documentation: the `partition_wal_usage` field comment and the `PartitionWALUsage` enum contract disagreed -- the field comment said a non-`kNone` value also tags the WAL file with an identifying marker record, which the enum's own documentation never mentioned. The on-disk contract now lives in one place, the enum header comment, and the field comment points at it instead of restating it.

Wiring: the field on `DBOptions` (default `kNone`) and `ImmutableDBOptions`, propagation in `BuildDBOptions`, registration via `OptionTypeInfo::Enum` against `GetPartitionWALUsageStringMap()`, the copy constructor, and `ROCKS_LOG_HEADER`. The string map accepts four keys -- a `kFoo` and a `snake_case` spelling for each of the two values (`kNone`/`none`, `kPartitionByColumnFamily`/`partition_by_column_family`) -- so OPTIONS files and the tooling flags all parse through one table.

`BuildDBOptions` propagation is easy to miss: `partition_wal_usage` lives only in `ImmutableDBOptions`, and `options_settable_test`, which would otherwise catch a missing assignment, is compiled out under clang.

M1: Absorbs GC04 options.h part (on-disk-format correction + procedure steps 1-4, 8; guard/steps 5-7 stay in S-A) and GC05 enum-doc part + `SetDBOptionsRejectsPartitionWALUsage` test (the `wal_partitions` sentence lives in D117251769).

C API: adds `rocksdb_options_set_partition_wal_usage` / `rocksdb_options_get_partition_wal_usage` (the enum passed as an `int`) to `include/rocksdb/c.h`, `db/c.cc` and the generated `c_api_gen` bindings and round-trip test, with `PartitionWALUsage` registered as an enum type in `tools/c_api_gen/auto_simple_bindings.py`.

Changes visible to existing users:
- New public option `DBOptions::partition_wal_usage` (default `kNone`). The WAL format does not change at the default.
- Every OPTIONS file now has a `partition_wal_usage=kNone` line.
- The info LOG header has one new line, `Options.partition_wal_usage: 0`.
- New C API functions `rocksdb_options_set_partition_wal_usage` and `rocksdb_options_get_partition_wal_usage`.

Test Plan:
Added one test to `options/options_test.cc`:

- `OptionsTest.PartitionWALUsageFromString` -- all four string-map keys (`kNone`, `none`, `kPartitionByColumnFamily`, `partition_by_column_family`), plus rejection of `bogus` and of the removed spellings `kRecordOrderingSingleFile` and `record_ordering_single_file`.

One in `db/db_options_test.cc`:

- `DBOptionsTest.SetDBOptionsRejectsPartitionWALUsage` -- `SetDBOptions` cannot change the option (`NotFound`), and the value stays `kNone`.

And one in `db/db_wal_test.cc`:

- `DBWALTest.PartitionWALUsageOpenValidation` -- `DB::Open` succeeds for both `kNone` and `kPartitionByColumnFamily`. It pins that this diff rejects neither value, so it has no neuter.

Also extended the `options_settable_test` settable chain with `partition_wal_usage`.

`test::RandomInitDBOptions` now randomizes `partition_wal_usage`, so the existing `OptionsTest.DBOptionsComposeImmutable` round trip (`DBOptions` -> `ImmutableDBOptions` -> `BuildDBOptions`) exercises the `BuildDBOptions` assignment when it draws `kPartitionByColumnFamily`. This was not neuter-verified.

```
$ buck2 build @fbcode//mode/dev-nosan fbcode//internal_repo_rocksdb/repo:options_test \
      fbcode//internal_repo_rocksdb/repo:db_wal_test fbcode//internal_repo_rocksdb/repo:log_test

$ options_test
[==========] 80 tests from 6 test suites ran. (99 ms total)
[  PASSED  ] 80 tests.

$ db_wal_test
[==========] 1983 tests from 8 test suites ran. (57055 ms total)
[  PASSED  ] 1983 tests.

$ log_test
[==========] 211 tests from 4 test suites ran. (741 ms total)
[  PASSED  ] 211 tests.
```

The same three suites pass at the top of the reviewed range (D120415420): 80, 2008 and 379 tests respectively. Every revision of the stack was checked out individually and compiles.

Formatting was 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`. `arc f` produced no edits and `arc lint -a` reports no issues.

M1: doc-only + 1 test; covered by tip `db_options_test` (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; db_options_test + db_wal_test + options_settable_test + options_test: 2123 pass.

M5 fold: Absorbs 4 A.1 entries (GC27 3, GC29a 1): GC27 Q9 (a): the PartitionWALUsage paragraph, the removal of PartitionWALUsageComposeImmutable, RandomInitDBOptions' partition_wal_usage part; GC29a Q2's rollback-step comment lines. Hand-splits (rows below the hunk's top row get their slice by a per-row edit): GC27#197 (options_test.cc): the removal of PartitionWALUsageComposeImmutable at D118367634 (which no longer adds it), PartitionWALOptionsRoundTrip at D117251769.

M5 B.1: PASS (clang-format 21.1.2 on the changed lines, make check-sources, debug build of db_options_test, db_wal_test, options_settable_test, options_test); 2122 tests, 0 failed.

Reviewers: taopeng, rajivharlalka, kinbertchou, xbw, huixiao

Subscribers: jewoongh, rbanerjee2, anand76, huixiao, jkangs, xbw

Differential Revision: https://phabricator.intern.facebook.com/D118367634

This branch has not been deployed

No deployments
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