Skip to content

Add WAL index record types to log_format (#15220) - #15220

Open
JustinGaoF wants to merge 2 commits into
meta:mainfrom
JustinGaoF:export-D118369740
Open

JustinGaoF wants to merge 2 commits into
meta:mainfrom
JustinGaoF:export-D118369740

Conversation

@JustinGaoF

@JustinGaoF JustinGaoF commented Sep 16, 2026 •

Copy link
Copy Markdown

Summary:

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types kWALIndexMarkerType (12) and kRecyclableWALIndexMarkerType (13) tag a file as carrying per-record ordering numbers. Indexed data record types kWALIndexFullType..kRecyclableWALIndexLastType (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds IsWALIndexRecordType, extends IsRecyclableRecordType to cover the new recyclable types, and defines kWALIndexSize = 8 for the fixed64 prefix.

All new types stay below kRecordTypeSafeIgnoreMask, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two static_asserts enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

Differential Revision: D118369740

@meta-codesync

meta-codesync Bot commented Sep 16, 2026

Copy link
Copy Markdown

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

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

Differential Revision: D118369740
@meta-codesync meta-codesync Bot changed the title Add WAL index record types to log_format Add WAL index record types to log_format (#15220) Sep 16, 2026
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

✅ clang-tidy: No findings on changed lines

Completed in 340.3s.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

Differential Revision: D118369740
@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 42007e7


Summary

Clean header-only PR that defines WAL index record types and a new PartitionWALUsage option. The record type design is sound with good fail-closed safety (verified by static_asserts). The main gaps are missing items from the new-option checklist (db_stress, db_bench, db_crashtest, release note, Java bindings) and a missing DB::Open validation for the not-yet-implemented kWALIndexPartitionByColumnFamily value, despite the documentation promising one.

High-severity findings (1):

  • [include/rocksdb/options.h:473] kWALIndexPartitionByColumnFamily documentation says "DB::Open rejects this value" but no validation code exists anywhere.
Full review (click to expand)

Findings

🔴 HIGH

H1. Missing DB::Open validation for kWALIndexPartitionByColumnFamily — include/rocksdb/options.h:473
  • Issue: The PartitionWALUsage enum documentation states: "NOT YET IMPLEMENTED: DB::Open rejects this value." However, no validation code is added in this PR. A user setting partition_wal_usage = PartitionWALUsage::kWALIndexPartitionByColumnFamily will succeed at DB::Open and silently have no effect (or cause undefined behavior when the writer is added in a future PR without the corresponding partitioning logic).
  • Root cause: The PR adds the enum value and documents the intended rejection but does not implement it.
  • Suggested fix: Add validation in DBImpl::Open() (or SanitizeOptions()) that returns Status::NotSupported() when partition_wal_usage == PartitionWALUsage::kWALIndexPartitionByColumnFamily. This ensures the contract documented in the public API is enforced from the start.

🟡 MEDIUM

M1. Missing db_stress, db_bench, db_crashtest support — per CLAUDE.md add_option checklist
  • Issue: The CLAUDE.md add_option.md checklist requires new options to have db_stress support (DECLARE in db_stress_common.h, DEFINE in db_stress_gflags.cc, apply in db_stress_test_base.cc), db_bench support (DEFINE and apply in db_bench_tool.cc), and db_crashtest.py randomized values. None of these are present.
  • Evidence: Grep for partition_wal_usage in db_stress_tool/ and tools/ returns no results.
  • Suggested fix: Add the standard db_stress/db_bench/db_crashtest plumbing, or if intentionally deferred (since the option has no effect yet), document the deferral explicitly and add a TODO.
M2. Missing release note — unreleased_history/
  • Issue: A new public API enum and option (PartitionWALUsage, DBOptions::partition_wal_usage) are added, but no release note file exists in unreleased_history/new_features/ or unreleased_history/public_api_changes/.
  • Evidence: Grep for partition_wal or PartitionWAL in unreleased_history/ returns no results.
  • Suggested fix: Add a brief release note, e.g., unreleased_history/public_api_changes/partition_wal_usage.md.
M3. Missing Java API bindings
  • Issue: No Java files are modified. Other enum-typed options (e.g., WALRecoveryMode) have Java bindings. If the option is public, Java users cannot set it.
  • Suggested fix: Add Java bindings, or if intentionally deferred, add an entry to the C API blocklist with "policy": "deferred" and a reason.
M4. IsRecyclableRecordType() not used by existing reader — future maintenance risk
  • Issue: The PR defines a new IsRecyclableRecordType() function in log_format.h, but db/log_reader.cc has three separate hardcoded recyclable-type checks (lines ~571-574, ~979-981, and within the switch statement) that do NOT use this function and do NOT include the new WAL index recyclable types. When a future PR adds the WAL index writer/reader, a developer must remember to update all three hardcoded sites OR refactor to use IsRecyclableRecordType().
  • Evidence: log_reader.cc:571-574:
    const bool is_recyclable_type =
        ((type >= kRecyclableFullType && type <= kRecyclableLastType) ||
         type == kRecyclableUserDefinedTimestampSizeType ||
         type == kRecyclePredecessorWALInfoType);
    This check is repeated at line ~979. Neither includes kRecyclableWALIndexMarkerType or kRecyclableWALIndex{Full,First,Middle,Last}Type.
  • Suggested fix: Consider adding a TODO comment near IsRecyclableRecordType() noting that log_reader.cc should be refactored to use it when WAL index reader support is added. Alternatively, refactor the reader now to use the centralized function (though this changes existing code in a "header-only" PR).

🟢 LOW / NIT

L1. Inconsistent string map initialization pattern — db_options.cc
  • Issue: GetPartitionWALUsageStringMap() uses a function-local static (CERT ERR58-CPP pattern), while the existing wal_recovery_mode_string_map and cache_tier_string_map use namespace-scope statics. The new pattern is safer, but the inconsistency may be confusing.
  • Suggested fix: No change needed (the new pattern is better). Consider a follow-up to migrate the older maps.
L2. String map supports both snake_case and CamelCase but WALRecoveryMode only has CamelCase
  • Issue: GetPartitionWALUsageStringMap() supports both "kNone" and "none", "kWALIndexSingleFile" and "wal_index_single_file". The existing wal_recovery_mode_string_map only has CamelCase keys ("kTolerateCorruptedTailRecords"). This is a minor inconsistency but arguably the new approach is more user-friendly.
  • Suggested fix: No change needed (the new approach is better for usability).
L3. Comment correction is good but could go further
  • Issue: The old misleading comment "For all the values >= 10, the 1 bit indicates whether it's recyclable" is replaced with an accurate statement. Good improvement. However, the new comment could also note that the hardcoded checks in log_reader.cc need updating when new recyclable types are added.
  • Suggested fix: Optional: add a note about the reader's hardcoded checks.
L4. kWALIndexSize naming
  • Issue: kWALIndexSize = 8 is defined as "Number of bytes of the fixed64 wal_index prefixed to each logical record." The name kWALIndexSize could be confused with the size of an index structure. A name like kWALIndexFieldSize or kWALIndexPrefixSize might be clearer.
  • Suggested fix: Consider renaming for clarity, but this is minor.

Cross-Component Analysis

Context Relevant? Assessment
Older RocksDB readers YES Correctly fail-closed: types 12-21 < 128, so the reader's default case reports corruption. Verified by static_asserts.
type_crc_ array YES Array is kMaxRecordType + 1 = 132 entries. Types 12-21 fit. No issue.
Recyclable header detection FUTURE RISK Reader hardcodes recyclable checks; new recyclable types not included. OK for now (no writer), but M4 tracks the risk.
Options serialization roundtrip YES Tested by PartitionWALUsageComposeImmutable and PartitionWALUsageFromString.
C API YES Auto-generated, uses int cast. Safe for valid values; no validation for out-of-range. Consistent with how other enum options work in the C API.

Positive Observations

  • The static_asserts enforcing fail-closed behavior are well-designed and prevent future renumbering mistakes.
  • The corrected comment about recyclability encoding removes a genuinely misleading piece of documentation.
  • The CERT ERR58-CPP pattern for the string map is a good improvement over the existing namespace-scope static pattern.
  • The test coverage for option serialization/deserialization is thorough, including negative test for invalid values.
  • The overall approach of landing record type definitions before the writer/reader implementation is sound for incremental review.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

Differential Revision: D118369740
@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 43ab2e6


Summary

Header-only PR adding WAL index record types and PartitionWALUsage option. The type numbering, static_asserts, and fail-closed downgrade safety are well-designed. The main concerns are: (1) the auto-generated C API roundtrip test exercises an invalid enum value, (2) several items from the option-adding checklist are missing, and (3) documentation in docs/components/write_flow/03_wal.md is now stale.

High-severity findings (1):

  • [c_api_gen/c_generated_roundtrip_tests.c.inc] Auto-generated C API roundtrip test stores invalid enum value 1 into PartitionWALUsage (valid values are 0 and 2), exercising undefined behavior via static_cast to an enum with no enumerator for that value.
Full review (click to expand)

Findings

🔴 HIGH

H1. C API roundtrip test uses invalid enum value -- c_api_gen/c_generated_roundtrip_tests.c.inc
  • Issue: The auto-generated roundtrip test (gen_roundtrip_tests.py:182-187) uses values 1 and 0 for all fields. For PartitionWALUsage, value 1 is not a valid enumerator (kNone=0x00, kPartitionByColumnFamily=0x02). The setter does static_cast<decltype(opt->rep.partition_wal_usage)>(v), which stores a value with no corresponding enumerator. While this is implementation-defined rather than UB in C++17 for enums with fixed underlying type (char), it means the roundtrip test is exercising a nonsensical state rather than validating actual enum values.
  • Root cause: The gen_roundtrip_tests.py generator always uses 1/0 test values (it cannot distinguish bool fields from enums via the C signature alone). The PartitionWALUsage enum intentionally skips value 0x01, creating a gap that the generator hits.
  • Suggested fix: Either (a) add PartitionWALUsage to the roundtrip-test blocklist in tools/c_api_gen/auto_simple_bindings_blocklist.json and write a manual roundtrip test using values 0 and 2, or (b) teach the generator about enum-specific test values (more complex). Alternatively, since the char underlying type makes the cast well-defined, this could be documented as acceptable -- but the test is still not validating the real enum values.

🟡 MEDIUM

M1. Missing db_stress / db_bench / crashtest / release note per add_option.md checklist
  • Issue: The claude_md/add_option.md checklist requires: db_stress_common.h (DECLARE), db_stress_gflags.cc (DEFINE), db_stress_test_base.cc (apply), tools/db_bench_tool.cc, tools/db_crashtest.py, and unreleased_history/ release note. None of these are present. The adjacent wal_compression option has all of these.
  • Root cause: This PR focuses on header-only groundwork. These may be planned for a follow-up.
  • Suggested fix: Either add them in this PR (at minimum the release note and db_stress wiring so the option gets stress-test coverage), or document in the PR description that these are deferred to the implementation PR. The release note is especially important since a new public API (PartitionWALUsage enum and DBOptions::partition_wal_usage) is being added.
M2. docs/components/write_flow/03_wal.md record type table and "bit 0" claim are now stale -- docs/components/write_flow/03_wal.md:40-53
  • Issue: The documentation at line 40-52 lists record types but does not include the new types 12-21. More critically, line 53 states "Types 10 and above use bit 0 to distinguish recyclable (odd) from non-recyclable (even) variants" which is incorrect for the new types (e.g., kWALIndexMarkerType=12 is even but non-recyclable, kRecyclableWALIndexMarkerType=13 is odd and recyclable, but kWALIndexFullType=14 is even and non-recyclable while kRecyclableWALIndexFullType=18 is even and recyclable). The PR correctly updates the code comment in log_format.h, but the docs are not updated.
  • Suggested fix: Update the record type table and replace the "bit 0" claim in the docs to match the corrected comment in log_format.h.
M3. No validation of partition_wal_usage on DB open -- db/db_wal_test.cc
  • Issue: The PartitionWALUsageOpenValidation test verifies that DB opens with both valid enum values. However, there is no validation that rejects kPartitionByColumnFamily since the feature is not implemented yet. A user setting partition_wal_usage = kPartitionByColumnFamily will get no error and no changed behavior -- silently doing nothing.
  • Root cause: The feature is marked EXPERIMENTAL, and the enum documentation says "Column-family routing is not implemented yet." However, a runtime validation (returning Status::NotSupported or similar when kPartitionByColumnFamily is set) would be safer.
  • Suggested fix: Add option validation in DBImpl::Open (or SanitizeOptions) that rejects kPartitionByColumnFamily until the feature is implemented. This prevents silent misconfiguration.
M4. No unit tests for IsWALIndexRecordType() or IsRecyclableRecordType() helper functions
  • Issue: These are new public (within the log namespace) helper functions with non-trivial logic (range checks, multiple conditions). Neither has any test coverage. IsRecyclableRecordType() in particular replaces what was previously inline code in the reader; when the reader is updated to use this function, any bug in it would cause header size misdetection and data corruption.
  • Suggested fix: Add unit tests in db/log_test.cc verifying correct classification for all defined record types and boundary values. A table-driven test iterating over all RecordType values would be ideal.

🟢 LOW / NIT

L1. PartitionWALUsage enum skips 0x01 with no comment explaining the gap
  • Issue: The enum has kNone = 0x00 and kPartitionByColumnFamily = 0x02. The test confirms a removed value name (kRecordOrderingSingleFile) no longer parses, but the enum definition has no comment explaining why 0x01 is reserved/removed.
  • Suggested fix: Add a brief comment: // 0x01 was kRecordOrderingSingleFile, removed before release.
L2. IsRecyclableRecordType() is dead code with no callers
  • Issue: The function is defined but never called. The existing reader has hardcoded inline checks at db/log_reader.cc:571-574 and db/log_reader.cc:979-981. When WAL index reader support is implemented, developers need to remember to refactor to use this function.
  • Suggested fix: Consider adding a // TODO: refactor log_reader.cc to use this function comment, or better yet, refactor the reader now (in a separate PR) to use this function for the existing types, establishing the pattern before new types are added.
L3. Writer's header format detection will need updating -- db/log_writer.cc:321-322
  • Issue: EmitPhysicalRecord determines legacy vs recyclable header format using if (t < kRecyclableFullType || t == kSetCompressionType || ...). The non-recyclable WAL index types (12-17) are >= kRecyclableFullType (5) and don't match the special-case exceptions, so they would incorrectly get recyclable header format if used by the current writer. This is not a bug in this PR (no writer changes), but is a latent issue for the implementation PR.
  • Suggested fix: Document this in a code comment or TODO near the new type definitions.
L4. Minor: static_assert coverage gap for future types
  • Issue: The static_assert lists each WAL index type individually. If a future developer adds another WAL index type but forgets to add it to the static_assert, the fail-closed guarantee is silently broken. A range-based assertion (e.g., asserting the max WAL index type < mask) would be more robust.
  • Suggested fix: Consider static_assert(kRecyclableWALIndexLastType < kRecordTypeSafeIgnoreMask, ...) as a single assertion, relying on the contiguous numbering to protect all intermediate values.
L5. Construct-on-first-use for GetPartitionWALUsageStringMap() but not for wal_recovery_mode_string_map
  • Issue: The PR correctly uses function-local static for the new string map (CERT ERR58-CPP), but the existing wal_recovery_mode_string_map (line 29) and cache_tier_string_map (line 38) are namespace-scope statics. This inconsistency is not introduced by this PR but is worth noting -- the new code is actually better.
  • Suggested fix: No action needed for this PR. The new pattern is correct.

Cross-Component Analysis

Context Affected? Assessment
Older reader encountering new types Yes Safe. Types 12-21 fall through to default: in reader switch. kRecordTypeSafeIgnoreMask check triggers ReportCorruption. In kSkipAnyCorruptedRecords mode, the reader continues past corruption, but this is expected behavior for that mode.
Writer CRC array No impact type_crc_[kMaxRecordType+1] = 132 entries. Types 12-21 are within range.
Writer header format Latent issue Non-recyclable WAL index types (12-17) would get recyclable header if written by current writer. No writer changes in this PR.
Recycled log detection Latent issue Reader's hardcoded recyclable checks don't include new types. When reader support is added, must use IsRecyclableRecordType().
WAL compression interaction Not tested When WAL compression + WAL indexing are both enabled, the decompression bypass list (log_reader.cc:638-642) will need updating for marker types.
Config file portability Safe Unknown option strings are rejected by default (ignore_unknown_options=false). Older binaries will fail to parse config files with partition_wal_usage.

Positive Observations

  • The fail-closed design via static_assert + type values below kRecordTypeSafeIgnoreMask is excellent defensive engineering.
  • The construct-on-first-use pattern for the string map is the correct modern C++ approach and improves on existing code.
  • The corrected comment in log_format.h (replacing the inaccurate "bit 1 indicates recyclable" claim) improves code documentation accuracy.
  • The test for rejected removed value names (kRecordOrderingSingleFile) provides good forward-compatibility coverage.
  • The option round-trip tests (ImmutableDBOptions, string parsing) are thorough.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

Differential Revision: D118369740
@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 4911518


Summary

Clean, well-structured header-only PR that adds WAL index record types and a PartitionWALUsage option. The fail-closed safety design (static_asserts keeping types below the safe-ignore mask) is sound. Several missing checklist items for the new option, one documentation inconsistency, and a latent writer-side concern for future implementers.

High-severity findings (1):

  • [db/log_format.h + db/log_writer.cc] IsRecyclableRecordType() is correct but NOT used by the existing writer/reader inline checks; worse, the writer's EmitPhysicalRecord logic will misclassify non-recyclable WAL index types (12-17) as recyclable when they are eventually emitted. Needs a documented TODO or guard.
Full review (click to expand)

Findings

🔴 HIGH

H1. Writer EmitPhysicalRecord will misclassify non-recyclable WAL index types -- db/log_writer.cc:321
  • Issue: The current writer logic at db/log_writer.cc:321-322 uses:
    if (t < kRecyclableFullType || t == kSetCompressionType ||
        t == kPredecessorWALInfoType || t == kUserDefinedTimestampSizeType)
    to determine legacy (7-byte) vs recyclable (11-byte) header format. Types 12-17 (kWALIndexMarkerType through kWALIndexLastType) are NOT less than kRecyclableFullType (5) and do NOT match any of the special-case types, so they fall into the else branch and are treated as recyclable format -- but they are NOT recyclable types. This means when a future PR writes these types, the header will be 11 bytes (with log number) instead of the correct 7 bytes, producing corrupt records.
  • Root cause: The recyclable detection logic was designed for the original type numbering where recyclable types were always >= 5. New non-recyclable types above 4 break this assumption.
  • Suggested fix: Since this PR is header-only and no code emits these types yet, add a prominent // TODO comment near the EmitPhysicalRecord logic or near the type definitions noting that the writer's recyclable detection must be updated to use IsRecyclableRecordType() (or equivalent) before any WAL index types are written. Alternatively, refactor EmitPhysicalRecord now to use the new IsRecyclableRecordType() function. Similarly, the reader's inline checks at log_reader.cc:571-574 and log_reader.cc:979-981 need updating.

🟡 MEDIUM

M1. Missing option checklist items per claude_md/add_option.md
  • Issue: The new partition_wal_usage option is missing several items required by the option addition checklist:
    • db_stress_tool/db_stress_common.h -- DECLARE flag
    • db_stress_tool/db_stress_gflags.cc -- DEFINE flag
    • db_stress_tool/db_stress_test_base.cc -- apply flag
    • tools/db_bench_tool.cc -- DEFINE and apply
    • tools/db_crashtest.py -- randomized values
    • unreleased_history/ -- release note
  • Suggested fix: Add these items, even if the feature is not yet functional. For db_stress/db_bench, setting only kNone is fine until the feature is implemented.
M2. Documentation inconsistency in docs/components/write_flow/03_wal.md -- docs/components/write_flow/03_wal.md:53
  • Issue: The docs state "Types 10 and above use bit 0 to distinguish recyclable (odd) from non-recyclable (even) variants." The PR correctly removes this misleading comment from log_format.h (the old comment said "For all the values >= 10, the 1 bit indicates whether it's recyclable"), but the same incorrect claim persists in the WAL component documentation. With the new types, this convention is NOT consistently followed (e.g., type 18 is even but recyclable).
  • Suggested fix: Update docs/components/write_flow/03_wal.md to reflect that recyclability is not encoded in the type value and should be checked via IsRecyclableRecordType().
M3. C API lacks input validation for enum values
  • Issue: The C API setter at db/c.cc (and c_api_gen/c_generated_option_structs_auto.cc.inc) uses static_cast<decltype(opt->rep.partition_wal_usage)>(v) to cast an int to PartitionWALUsage. Passing v=1 produces an unnamed enum value (0x01 is not defined). No validation rejects invalid values.
  • Suggested fix: This is consistent with how other enum C API setters work in RocksDB (e.g., wal_compression, wal_recovery_mode all do unchecked casts), so this is a pre-existing pattern rather than a new defect. However, consider adding a note that C API callers should only use defined enum values.

🟢 LOW / NIT

L1. GetPartitionWALUsageStringMap uses function-local static while peers use namespace-scope static -- options/db_options.cc:39
  • Issue: The new map uses the CERT ERR58-CPP compliant construct-on-first-use pattern (function-local static), while wal_recovery_mode_string_map and cache_tier_string_map at the top of the same file use namespace-scope statics. The comment explains the rationale well, but the inconsistency within the same file may confuse future contributors.
  • Suggested fix: The new pattern is actually better. Consider noting that the old maps should be migrated in a separate cleanup PR, or just accept the inconsistency.
L2. No unit tests for IsWALIndexRecordType() and IsRecyclableRecordType()
  • Issue: These are new inline constexpr functions that define a critical contract (which types are recyclable, which are WAL-index). While they're simple range checks, a unit test would guard against future type renumbering breaking them.
  • Suggested fix: Add a small test in an existing test file (e.g., db/log_test.cc or db/db_etc3_test.cc) that verifies IsWALIndexRecordType and IsRecyclableRecordType return correct values for all defined record types.
L3. IsWALIndexRecordType excludes marker types -- db/log_format.h
  • Issue: IsWALIndexRecordType() returns true for types 14-21 (data record types) but NOT for types 12-13 (marker types). The function name could be read as "is this any WAL-index-related type" vs "is this a WAL-index DATA type." The current behavior matches the comment ("Data records carrying a leading wal_index") but the function name is slightly ambiguous.
  • Suggested fix: Either rename to IsWALIndexDataRecordType() or add a brief doc comment on the function clarifying it excludes markers.
L4. PartitionWALUsage enum skips value 0x01
  • Issue: The enum has kNone = 0x00 and kPartitionByColumnFamily = 0x02, with the test explicitly checking that old value names like kRecordOrderingSingleFile are rejected. The gap at 0x01 is intentional (removed value). The serialization uses string-based mapping so the gap is harmless for options files, but if anyone ever serializes the raw integer, 0x01 becomes an undocumented invalid value.
  • Suggested fix: This is fine as-is. The gap documents design history and the string-based serialization avoids the issue.

Cross-Component Analysis

Concern Status Notes
Fail-closed on older readers Safe static_asserts enforce types < 128; reader default case reports corruption
type_crc_ array bounds Safe kMaxRecordType unchanged at 131; new types 12-21 within bounds
Option round-trip Tested PartitionWALUsageComposeImmutable test covers DBOptions -> ImmutableDBOptions -> BuildDBOptions
Option string parsing Tested PartitionWALUsageFromString tests valid and invalid names
Reader error sentinel values Safe kEof=132, kBadRecord=133, etc. (kMaxRecordType+1..+6) -- no collision with new types
WritePreparedTxnDB N/A No runtime behavior change
ReadOnly DB N/A No runtime behavior change

Positive Observations

  • The static_assert pattern for fail-closed safety is well-designed and the comment clearly explains the rationale.
  • The corrected comment removing the misleading "bit 0 indicates recyclability" claim is a good cleanup.
  • The CERT ERR58-CPP pattern for the option string map is a genuine improvement over the existing namespace-scope statics.
  • Test coverage for the option system is thorough (round-trip, string parsing, settable test, C API round-trip, DB open validation).
  • The incremental approach (header-only first, implementation later) is good engineering practice for a complex feature.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

Differential Revision: D118369740
@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 494b7dc


Summary

Header-only PR that adds WAL index record types and a PartitionWALUsage option. The core log_format.h changes are well-designed with proper fail-closed static_asserts. The main gaps are in option infrastructure completeness (missing db_stress, db_bench, crash test, Java bindings, release notes) and a potential future writer/reader integration issue with header format classification for non-recyclable WAL index types.

High-severity findings (1):

  • [db/log_writer.cc:321] EmitPhysicalRecord() header format logic will misclassify non-recyclable WAL index types (12-17) as recyclable, emitting incorrect headers when a future writer uses these types.
Full review (click to expand)

Findings

🔴 HIGH

H1. EmitPhysicalRecord() will emit recyclable headers for non-recyclable WAL index types — db/log_writer.cc:321
  • Issue: The header format decision in EmitPhysicalRecord() uses:
    if (t < kRecyclableFullType || t == kSetCompressionType ||
        t == kPredecessorWALInfoType || t == kUserDefinedTimestampSizeType) {
      header_size = kHeaderSize;  // Legacy
    } else {
      header_size = kRecyclableHeaderSize;  // Recyclable
    }
    Non-recyclable WAL index types kWALIndexMarkerType (12), kWALIndexFullType-kWALIndexLastType (14-17) are all >= kRecyclableFullType (5) and are not in the explicit exception list. They will fall through to the recyclable branch, getting a kRecyclableHeaderSize (11-byte) header with log number — even though they are non-recyclable types that should use the legacy 7-byte header.
  • Root cause: The writer's header format logic predates WAL index types and assumes everything >= 5 that isn't explicitly listed is recyclable. The PR adds new non-recyclable types in the range 12-17 without updating this logic.
  • Suggested fix: When the writer is implemented in a follow-up PR, this condition MUST be updated. Consider adding a comment or TODO near this code now to flag the required change, or better yet, refactor to use the new IsRecyclableRecordType() function:
    if (IsRecyclableRecordType(t)) {
      header_size = kRecyclableHeaderSize;
    } else {
      header_size = kHeaderSize;
    }
    Similarly, the reader's ReadPhysicalRecord() at line 571-574 and FragmentBufferedReader::TryReadFragment() at line 979-981 have hardcoded recyclable type checks that need updating to use IsRecyclableRecordType().

🟡 MEDIUM

M1. Missing db_stress, db_bench, crash test support for partition_wal_usage
  • Issue: Per the add_option.md checklist, new options should have db_stress (DECLARE/DEFINE/apply), db_bench, and db_crashtest.py support. The sibling option wal_compression has all three. None are present for partition_wal_usage.
  • Suggested fix: Add db_stress flag declaration, definition, and application. Add db_bench flag. Add crash test randomization. This can be done in this PR or a follow-up, but should be tracked.
M2. Missing release notes in unreleased_history/
  • Issue: No release note file exists in unreleased_history/new_features/ or unreleased_history/public_api_changes/ for the new PartitionWALUsage enum and partition_wal_usage option. Per the add_option.md checklist and CLAUDE.md, this is required for new public API additions.
  • Suggested fix: Add a file like unreleased_history/new_features/partition_wal_usage.md with a one-line description, and unreleased_history/public_api_changes/partition_wal_usage.md for the public API change.
M3. No input validation for partition_wal_usage option value
  • Issue: There is no validation in SanitizeOptions(), ValidateOptions(), or DBImpl::Open() for the partition_wal_usage value. An invalid enum value (e.g., 0x01 or 0x03) would be accepted silently. The C API uses static_cast<decltype(opt->rep.partition_wal_usage)>(v) which can produce an invalid enum value from any int.
  • Suggested fix: Add validation in the DB open path that rejects unknown PartitionWALUsage values. At minimum, the C API setter should validate the input range.
M4. Missing Java/JNI bindings
  • Issue: No Java bindings exist for PartitionWALUsage or partition_wal_usage. While the sibling option wal_compression also lacks Java bindings, the add_public_api.md guide lists Java support as required. Since this is EXPERIMENTAL, this may be acceptable as a deferral.
  • Suggested fix: Either add Java bindings or document the deferral with a tracking issue.

🟢 LOW / NIT

L1. IsWALIndexRecordType() excludes marker types — naming may confuse callers
  • Issue: IsWALIndexRecordType() returns true only for data record types (14-21), not marker types (12-13). The name "WALIndexRecordType" could reasonably be interpreted to include markers. The function is not used yet, so this is a naming/documentation concern.
  • Suggested fix: Consider renaming to IsWALIndexDataRecordType() or adding a brief comment clarifying that markers are excluded. Alternatively, add an IsWALIndexMarkerType() helper.
L2. kWALIndexSize uses uint32_t — unusual for a size constant
  • Issue: constexpr uint32_t kWALIndexSize = 8; uses uint32_t. Other size constants in the same file use unsigned int (kBlockSize) or int (kHeaderSize). Using size_t would be more idiomatic for a byte count, though uint32_t is fine in practice.
  • Suggested fix: Consider using constexpr int kWALIndexSize = 8; for consistency with kHeaderSize and kRecyclableHeaderSize, or document why uint32_t was chosen.
L3. Inconsistent static initialization pattern for string map
  • Issue: GetPartitionWALUsageStringMap() uses a function-local static (CERT ERR58-CPP) while the existing wal_recovery_mode_string_map and cache_tier_string_map are namespace-scope statics. The function-local pattern is actually safer (avoids potential static initialization order issues), but the inconsistency may be confusing.
  • Suggested fix: No change needed for this PR — the function-local static is an improvement. Consider eventually migrating the older maps to this pattern in a separate cleanup.
L4. Old inaccurate comment about "bit 1 indicates recyclable" is correctly replaced
  • Issue: The old comment "For all the values >= 10, the 1 bit indicates whether it's recyclable" was already inaccurate (types 130/131 don't follow this pattern). The PR correctly replaces it with a more accurate description.
  • Suggested fix: None — this is a positive observation.
L5. Gap at 0x01 in PartitionWALUsage enum not documented
  • Issue: PartitionWALUsage uses kNone = 0x00 and kPartitionByColumnFamily = 0x02 with no 0x01 value. The test mentions "kRecordOrderingSingleFile" as a removed value. The gap should be briefly documented in the enum to prevent someone from accidentally reusing 0x01 with different semantics.
  • Suggested fix: Add a comment like // 0x01 was kRecordOrderingSingleFile, removed before initial release in the enum.

Cross-Component Analysis

Component Impact Status
log_writer.cc EmitPhysicalRecord Header format misclassification for types 12-17 Must fix in follow-up (H1)
log_reader.cc ReadPhysicalRecord Recyclable type check doesn't include 18-21 Must fix in follow-up
log_reader.cc FragmentBufferedReader Same recyclable type check gap Must fix in follow-up
log_reader.cc decompression bypass Types 12-13 (markers) not in bypass list Benign: markers have no payload
type_crc_[] array Types 12-21 within bounds (< 132) Safe
Option validation No validation of partition_wal_usage Should add (M3)
db_stress / db_bench / crashtest No support Should add (M1)
Java/JNI No bindings Should add or defer (M4)
Release notes Missing Should add (M2)

Positive Observations

  • The static_asserts are well-designed and prevent the most dangerous misconfiguration (WAL index types in the ignorable range).
  • The "fail closed" design is sound: older readers will correctly reject unknown types < 128 as corruption.
  • The new IsRecyclableRecordType() function is a good consolidation of the previously scattered inline checks.
  • The function-local static for the string map is a genuine improvement over the namespace-scope static pattern (CERT ERR58-CPP).
  • The test for removed "kRecordOrderingSingleFile" value ensures forwards compatibility.
  • The PartitionWALUsageComposeImmutable test specifically catches a class of bug (missing BuildDBOptions assignment) that can be easy to miss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. A `static_assert` naming all ten WAL index types enforces that, so renumbering any of them into the ignorable range breaks the build instead of turning into silent data loss.

Differential Revision: D118369740
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

✅ Claude Code Review

Auto-triggered after CI passed — reviewing commit 1dfa092


Summary

This PR adds WAL index record types to log_format.h and a new PartitionWALUsage option. The header-only approach is sound and the fail-closed safety design is well-reasoned. Two high-severity findings: (1) the writer's legacy/recyclable header-size logic in EmitPhysicalRecord will misclassify non-recyclable WAL index types when writer support is added, and (2) the IsRecyclableRecordType() function introduced here is not used by the reader's existing recyclable-detection code, creating a maintenance trap.

High-severity findings (2):

  • [log_writer.cc:321] EmitPhysicalRecord determines header size with t < kRecyclableFullType — new non-recyclable WAL index types (12, 14-17) will get the wrong header size when writer support is added.
  • [log_reader.cc:571] Reader's hardcoded recyclable-type detection is not updated and does not use the new IsRecyclableRecordType(), creating a maintenance trap for the follow-up PR.
Full review (click to expand)

Findings

🔴 HIGH

H1. Writer's header-size logic will misclassify non-recyclable WAL index types — log_writer.cc:321
  • Issue: EmitPhysicalRecord() uses t < kRecyclableFullType (i.e., t < 5) to decide legacy vs recyclable header size, with explicit exceptions for kSetCompressionType, kPredecessorWALInfoType, and kUserDefinedTimestampSizeType. The new non-recyclable types kWALIndexMarkerType (12), kWALIndexFullType (14), kWALIndexFirstType (15), kWALIndexMiddleType (16), and kWALIndexLastType (17) are all >= 5 and not in the exception list. When a future PR adds writer support, these types will be written with kRecyclableHeaderSize (11 bytes) instead of kHeaderSize (7 bytes), producing CRC mismatches on read.
  • Root cause: The writer's header-size determination predates the new type numbering. Types 10 (kUserDefinedTimestampSizeType) and 130 (kPredecessorWALInfoType) were already handled as special exceptions, but the new types 12-17 are not.
  • Suggested fix: Either add the non-recyclable WAL index types to the exception list in EmitPhysicalRecord now (since this PR defines the types), or at minimum add a prominent // TODO comment and/or a static_assert that forces the writer to be updated when these types are used. Better yet, refactor to use the new IsRecyclableRecordType() in the writer too. Note the same pattern exists in the reader at ReadPhysicalRecord (line 571-574) and TryReadFragment (line 979-981).
H2. IsRecyclableRecordType() defined but not used by existing reader code — log_reader.cc:571, log_reader.cc:979
  • Issue: The PR introduces IsRecyclableRecordType() as a centralized helper, but the two existing recyclable-type checks in Reader::ReadPhysicalRecord() (line 571-574) and FragmentBufferedReader::TryReadFragment() (line 979-981) are hardcoded and not updated to use it. When the follow-up PR adds writer+reader support, a developer must remember to update THREE separate locations (the two reader spots plus the writer). If any is missed, recyclable WAL index records will be read with the wrong header size.
  • Root cause: The function is introduced as "future infrastructure" but the existing code isn't refactored to use it.
  • Suggested fix: Either refactor the reader now to use IsRecyclableRecordType() (the safe approach), or add a comment at each hardcoded location pointing to IsRecyclableRecordType() and explaining why they must be kept in sync.

🟡 MEDIUM

M1. Missing option checklist items per add_option.md — various files
  • Issue: Per the project's add_option.md checklist, a new option requires: db_stress support (3 files), db_bench support, db_crashtest.py, and an unreleased_history release note. None of these are present.
  • Suggested fix: Either add them in this PR or explicitly note they will come in a follow-up PR. At minimum, the release note should accompany the option addition. If the option is not yet functional (since there's no writer/reader), consider deferring the option to the PR that implements the behavior.
M2. No input validation for partition_wal_usage — db_impl_open.cc:245
  • Issue: DBImpl::ValidateOptions() does not validate partition_wal_usage. The C API accepts arbitrary int values which are static_cast to the enum type — values other than 0x00 and 0x02 are undefined behavior per the C++ standard (enum with fixed underlying type char). Additionally, there's no validation of incompatible option combinations (e.g., with wal_compression, allow_2pc, or unordered_write).
  • Suggested fix: Add validation in ValidateOptions() to reject unknown enum values, and document any known incompatibilities.
M3. C API static_cast from int to PartitionWALUsage is technically UB for out-of-range values — db/c.cc, c_api_gen/c_generated_option_structs_auto.cc.inc
  • Issue: static_cast<decltype(opt->rep.partition_wal_usage)>(v) where v is an arbitrary int can produce undefined behavior if v is not a valid enumerator value for PartitionWALUsage (which has underlying type char). While this pattern matches other enum options in the C API, it remains a hazard.
  • Suggested fix: Add range validation before the cast, or document that the C API caller is responsible for passing valid values.
M4. Decompression bypass list needs future update — log_reader.cc:638
  • Issue: The WAL index marker types carry no payload but are not in the decompression bypass list at ReadPhysicalRecord line 638-642. When WAL compression and WAL index are both enabled, the marker records would be incorrectly decompressed.
  • Root cause: Same pattern as H2 — future infrastructure without updating existing code.
  • Suggested fix: Add a comment at line 638 noting that WAL index marker types must be added when reader support is implemented, or add them now (they're no-ops since the reader doesn't handle them yet).

🟢 LOW / NIT

L1. Enum value gap at 0x01 should be documented — include/rocksdb/options.h
  • Issue: PartitionWALUsage jumps from kNone = 0x00 to kPartitionByColumnFamily = 0x02. The test confirms kRecordOrderingSingleFile was removed. The gap should have a comment explaining it's reserved or was removed.
  • Suggested fix: Add a comment like // 0x01 was kRecordOrderingSingleFile, removed before public release.
L2. Comment correction is good — log_format.h:41
  • Issue: The old comment "For all the values >= 10, the 1 bit indicates whether it's recyclable" was misleading. The new comment correctly notes that recyclability is not encoded uniformly in the type value. This is a positive change.
L3. ImmutableDBOptions field placement is efficient — db_options.h:89
  • Issue: None — the PartitionWALUsage field (char-sized) is placed between CompressionType (char) and bool, avoiding padding waste. Good.
L4. GetPartitionWALUsageStringMap() uses function-local static — db_options.cc
  • Issue: None — the function-local static pattern avoids CERT ERR58-CPP issues with namespace-scope static initialization. This is better than the existing wal_recovery_mode_string_map pattern (which uses namespace-scope statics). The comment explaining why is appreciated.
L5. Test PartitionWALUsageOpenValidation is minimal — db_wal_test.cc:3582
  • Issue: The test only verifies that TryReopen succeeds. Since the option has no effect yet (no writer/reader changes), this test is essentially a no-op. It's fine as a placeholder but should be expanded when behavior is added.

Cross-Component Analysis

Context Does code execute? Assumptions hold? Action needed?
WritePreparedTxnDB N/A (no behavior change) N/A None now
ReadOnly DB N/A N/A None now
WAL compression N/A now, but see M4 Marker types not in bypass list Fix in follow-up
Recycled WAL files N/A now, but see H1/H2 Writer/reader recyclable detection wrong Fix before writer PR
Old binary reading new WAL Fail-closed verified static_asserts enforce Safe

The static_asserts at compile time ensure WAL index types stay below kRecordTypeSafeIgnoreMask (128). The reader's default case reports corruption for unknown types below this mask. Together, these guarantee that an older binary will reject a WAL with index records rather than silently misinterpreting it. This safety design is sound.

Positive Observations

  • The fail-closed design with static_assert enforcement is well-thought-out and prevents a class of silent data loss bugs.
  • The comment explaining marker positional semantics (first record in file) is helpful.
  • The IsWALIndexRecordType() and IsRecyclableRecordType() helpers are good centralization, even if not yet used everywhere.
  • Function-local static for GetPartitionWALUsageStringMap() is an improvement over older patterns.
  • The option placement in ImmutableDBOptions (not MutableDBOptions) is correct — changing WAL format mid-run would be unsafe.

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

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:

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

Differential Revision: D118369740
Summary:
Pull Request resolved: meta#15220

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. Two `static_assert`s enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. A `static_assert` naming all ten WAL index types enforces that, so renumbering any of them into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType`, extends `IsRecyclableRecordType` to cover the new recyclable types, and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, which is what makes indexed WALs fail closed: an older binary must reject an indexed record rather than silently ignore it and report success. A `static_assert` naming all ten WAL index types enforces that, so renumbering any of them into the ignorable range breaks the build instead of turning into silent data loss.

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

Adds the WAL index record types to the log format. Header-only; no writer, reader or on-disk change yet.

Marker types `kWALIndexMarkerType` (12) and `kRecyclableWALIndexMarkerType` (13) tag a file as carrying per-record ordering numbers. Indexed data record types `kWALIndexFullType`..`kRecyclableWALIndexLastType` (14-21) mirror the existing full/first/middle/last set, with a recyclable twin for each, so every existing record shape has an indexed counterpart. Each fragment is self-describing: the marker is not required to decode a record, and the marker itself carries no payload.

Also adds `IsWALIndexRecordType` and a new `IsRecyclableRecordType` predicate (the existing recyclable types plus the new recyclable marker and indexed types, replacing hand-written checks in the writer and readers in the diffs above), and defines `kWALIndexSize = 8` for the fixed64 prefix.

All new types stay below `kRecordTypeSafeIgnoreMask`, so an older binary reports an indexed record as an unknown type instead of silently skipping it. The report fails Open only in the strict recovery modes. Under point-in-time or skip recovery the older binary stops replaying that file and opens without its records. A `static_assert` naming all ten WAL index types enforces that, so renumbering any of them into the ignorable range breaks the build instead of turning into silent data loss.

M1: Absorbs GC04 log_format.h parts (marker comment, 'reports on record #1', safe-ignore paragraph; 2-line guard sentence stays in S-A).

Test Plan:
Header-only change; covered by the consumers in the diffs above and by compile-time assertions here.

- The `static_assert` on `kRecordTypeSafeIgnoreMask` names every one of the ten WAL index types, so renumbering any of them into the safe-ignore range fails the build. An earlier revision asserted only two of the ten; the other eight were unguarded.
- `buck2 run fbcode//internal_repo_rocksdb/repo:log_test` at this diff — 211 tests pass.
- `arc lint -a fbcode/internal_repo_rocksdb/repo/db/log_format.h` — no issues.

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

M1: doc-only; 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 librocksdb build; no test file touched): PASS.

Reviewers: rajivharlalka, kinbertchou, taopeng, rbanerjee2, jkangs, anand76, huixiao

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

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

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