Repository navigation
Add WAL index record types to log_format (#15220) - #15220
JustinGaoF wants to merge 2 commits into
Conversation
45471bb to
94757ef
Compare
94757ef to
29d443b
Compare
|
@JustinGaoF has exported this pull request. If you are a Meta employee, you can view the originating Diff in 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
29d443b to
86a824b
Compare
✅ clang-tidy: No findings on changed linesCompleted in 340.3s. |
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
86a824b to
994ca6a
Compare
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
994ca6a to
160b0a7
Compare
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
160b0a7 to
a02efd0
Compare
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: 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
a02efd0 to
42007e7
Compare
Claude Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 42007e7 SummaryClean header-only PR that defines WAL index record types and a new High-severity findings (1):
Full review (click to expand)Findings🔴 HIGHH1. Missing DB::Open validation for
|
| 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
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: 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
42007e7 to
64b84ea
Compare
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: 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: 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
64b84ea to
43ab2e6
Compare
Claude Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 43ab2e6 SummaryHeader-only PR adding WAL index record types and High-severity findings (1):
Full review (click to expand)Findings🔴 HIGHH1. C API roundtrip test uses invalid enum value --
|
| 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 belowkRecordTypeSafeIgnoreMaskis 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
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
43ab2e6 to
4911518
Compare
Claude Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 4911518 SummaryClean, well-structured header-only PR that adds WAL index record types and a High-severity findings (1):
Full review (click to expand)Findings🔴 HIGHH1. Writer
|
| 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
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: 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
4911518 to
58dc7e9
Compare
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
58dc7e9 to
494b7dc
Compare
Claude Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 494b7dc SummaryHeader-only PR that adds WAL index record types and a High-severity findings (1):
Full review (click to expand)Findings🔴 HIGHH1.
|
| 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
PartitionWALUsageComposeImmutabletest 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
494b7dc to
b663bb7
Compare
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: 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
b663bb7 to
1dfa092
Compare
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. 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
✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 1dfa092 SummaryThis PR adds WAL index record types to High-severity findings (2):
Full review (click to expand)Findings🔴 HIGHH1. Writer's header-size logic will misclassify non-recyclable WAL index types —
|
| 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_assertenforcement 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()andIsRecyclableRecordType()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(notMutableDBOptions) 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
1dfa092 to
a9ebb4e
Compare
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
a9ebb4e to
6a2ef33
Compare
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
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
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
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) andkRecyclableWALIndexMarkerType(13) tag a file as carrying per-record ordering numbers. Indexed data record typeskWALIndexFullType..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, extendsIsRecyclableRecordTypeto cover the new recyclable types, and defineskWALIndexSize = 8for 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. Twostatic_asserts enforce that, so renumbering into the ignorable range breaks the build instead of turning into silent data loss.Differential Revision: D118369740