Skip to content

Add internal MANIFEST row model and row changes of each MANIFEST write - #15734

Open
xingbowang wants to merge 1 commit into
meta:mainfrom
xingbowang:export-D133208529
Open

xingbowang wants to merge 1 commit into
meta:mainfrom
xingbowang:export-D133208529

Conversation

@xingbowang

@xingbowang xingbowang commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary:
Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in VersionSet::ProcessManifestWrites()) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes and applies them to a debug copy of the rows. The check then compares the number and level of every SST in each new Version, and the persisted SST fields of the files whose rows the write adds or updates. The phase table at debug_manifest_rows_ in db/version_set.h lists the column family, blob file, DB and WAL checks. "In-memory differences" in db/manifest_rows.h lists the differences that the check allows. A mismatch stops the process with an assert.

Implementation
Key choices:

  • The rules that turn one MANIFEST write into row changes are in the BuildManifestRowChanges() comment in db/manifest_rows.h.
  • The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, full_history_ts_low, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, a compare of the WAL rows with the live WAL set in place (O(live WALs), with no copy), and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
  • When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
  • Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of db/manifest_rows.h lists these values.

Safety
No format change, no public API change and no behavior change in release builds.

  • VersionSet::GetManifestRows() requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
  • In debug builds, ProcessManifestWrites() copies the metadata of every live file into debug_manifest_rows_ on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The cost of this copy was not measured. The first call is the first LogAndApply() of the VersionSet. That call is often the MANIFEST write of DB::Open(). It can also be a call that writes no MANIFEST record, such as the dummy edit of DB::SetOptions().
  • On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, an in-place compare of the WAL rows (O(live WALs), with no copy), and O(levels) for a column family that the write adds.
  • Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:

  • VersionSet::GetManifestRows() never produces rows of dropped column families; ManifestRowsToRecords() skips such rows when they are given.
  • Rows of the files and blob files of a dropped column family stay in the rows after ApplyManifestRowChanges(); ManifestRowsToRecords() skips them. The comment of ManifestCfRow::dropped describes these rows.
  • Recovery from the records of ManifestRowsToRecords() sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first LogAndApply() of the VersionSet, and again after a rejected WAL edit.

How to read this diff

  1. db/manifest_rows.h: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from ManifestDbRow to ManifestRows, with the layout diagram.
  2. State to rows: the VersionSet::GetManifestRows() declaration in db/version_set.h, then in db/manifest_rows.cc MakeManifestCfRow(), MakeBlobFileRow(), MakeFileRow(), SetManifestCfRows() and VersionSet::GetManifestRows().
  3. Rows to records and comparison: ManifestRowsToRecords() (its comment gives the record order and the differences from VersionSet::WriteCurrentStateToManifest()), read next to WriteCurrentStateToManifest() in db/version_set.cc; then SameCfRow(), SameFileRow() and ManifestRowsEqual().
  4. Row changes: ManifestRowChanges and ApplyManifestRowChanges(); then ManifestBatchVersion and the BuildManifestRowChanges() comment, which holds all rules, and its code. BaseReferencedVersionBuilder::version() in db/version_builder.h is a one-line accessor for the base Version.
  5. Debug check: the debug_manifest_rows_ comment in db/version_set.h (timeline, phase table, threads); the three #ifndef NDEBUG hooks in VersionSet::ProcessManifestWrites(); then in db/manifest_rows.cc MakeManifestBatchVersions(), DebugCheckRowsBeforeInstall(), AssertCfRowsMatchVersion() and DebugCheckRowsAfterInstall().
  6. Tests in db/version_set_test.cc: ManifestRowFieldOfTag() and ManifestRowFieldOfNewFileTag() (the checklist for new tags), then ManifestRowsRoundTrip and ManifestRowChangesMatchVersions.
    The build files (src.mk, CMakeLists.txt, BUCK) only add the new source file.

Differential Revision: D133208529

@meta-codesync

meta-codesync Bot commented Nov 19, 2026

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

⚠️ clang-tidy: 7 warning(s) on changed lines

Completed in 418.1s.

Summary by check

Check Count
bugprone-argument-comment 7
Total 7

Details

db/version_set_test.cc (7 warning(s))
db/version_set_test.cc:1460:48: warning: argument name 'db_directory' in comment does not match parameter name 'dir_contains_current_file' [bugprone-argument-comment]
db/version_set_test.cc:3252:39: warning: argument name 'count' in comment does not match parameter name 'garbage_blob_count' [bugprone-argument-comment]
db/version_set_test.cc:3252:52: warning: argument name 'bytes' in comment does not match parameter name 'garbage_blob_bytes' [bugprone-argument-comment]
db/version_set_test.cc:3471:37: warning: argument name 'count' in comment does not match parameter name 'garbage_blob_count' [bugprone-argument-comment]
db/version_set_test.cc:3471:50: warning: argument name 'bytes' in comment does not match parameter name 'garbage_blob_bytes' [bugprone-argument-comment]
db/version_set_test.cc:3477:39: warning: argument name 'count' in comment does not match parameter name 'garbage_blob_count' [bugprone-argument-comment]
db/version_set_test.cc:3477:52: warning: argument name 'bytes' in comment does not match parameter name 'garbage_blob_bytes' [bugprone-argument-comment]

@xingbowang
xingbowang force-pushed the export-D133208529 branch 2 times, most recently from a8275d7 to f6e291e Compare November 19, 2026 17:56
@meta-codesync meta-codesync Bot changed the title Add an internal row model of the MANIFEST state Add internal MANIFEST row model and row changes of each MANIFEST write Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 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 e915b65


Summary

Well-structured addition of an internal MANIFEST row model with thorough debug-build verification. The two-phase debug check design correctly accounts for mutex boundaries, and the row model faithfully mirrors the existing VersionEdit/VersionSet state. No release-build impact.

High-severity findings (0):

No high-severity findings.

Full review (click to expand)

Findings

🔴 HIGH

None.

🟡 MEDIUM

M1. GetManifestRows() cost under DB mutex at first PMW call — db/version_set.cc:6115
  • Issue: debug_manifest_rows_ initialization calls GetManifestRows() which copies metadata of every live file, while holding the DB mutex. For a DB with 100K+ files this is a non-trivial amount of work under the mutex (allocations, string copies for keys/checksums, etc.).
  • Root cause: The initialization happens on the first ProcessManifestWrites() call, which in a normal DB is during DB::Open() before other threads are active. However, the same code path also re-initializes after a rejected WAL edit (debug_manifest_rows_.reset() in DebugCheckRowsBeforeInstall), which could happen during normal operation.
  • Suggested fix: Since this is debug-only, the cost is acceptable for correctness verification. The PR description already documents this ("In a DB the first call is normally the MANIFEST write of DB::Open(), before other threads use the DB"). The WAL-rejection re-fill is a rare event. Consider adding a comment at the re-fill site noting the mutex-held cost is acceptable because WAL rejection is rare.
M2. ManifestRowsToRecords always writes DB id; WriteCurrentStateToManifest gates on write_dbid_to_manifest — db/manifest_rows.cc (ManifestRowsToRecords)
  • Issue: ManifestRowsToRecords() writes the DB id whenever it is non-empty, regardless of write_dbid_to_manifest. WriteCurrentStateToManifest() only writes it when db_options_->write_dbid_to_manifest is true. The PR header documents this intentional difference, and recovery accepts the DB id regardless, so this is safe. However, a round-trip through ManifestRowsToRecords would produce a MANIFEST with the DB id even if the original DB was configured not to write it.
  • Root cause: Intentional design choice documented in the ManifestRowsToRecords header comment.
  • Suggested fix: No code change needed, but verify that the ManifestRowsRoundTrip test accounts for this (it does: GetManifestRows populates db_id from the in-memory state regardless of the option).
M3. SameFileRow comparison via full encode/decode — db/manifest_rows.cc
  • Issue: SameFileRow() creates two VersionEdit objects, calls AddExistingFile on each, encodes both to strings, and compares the strings. This is correct but relatively expensive for a comparison function. It's called from ManifestRowsEqual which iterates all files of all column families.
  • Root cause: Intentional design to avoid maintaining a separate comparison function that must be updated for each new FileMetaData field.
  • Suggested fix: Acceptable trade-off for debug/test code. The PR header documents the rationale: "a new persisted FileMetaData field then needs no change in the comparison."

🟢 LOW / NIT

L1. Missing operator== on ManifestCfRow and ManifestFileRow — db/manifest_rows.h
  • Issue: ManifestDbRow and ManifestBlobFileRow have operator==, but ManifestCfRow and ManifestFileRow do not. ManifestCfRow uses SameCfRow() for comparison (which has special InternalKey comparison logic), and ManifestFileRow uses SameFileRow() (encode-based comparison). This asymmetry is intentional but could be documented.
  • Suggested fix: Consider adding a brief comment in the struct definitions explaining why operator== is not provided (InternalKey doesn't have a simple equality, and file rows use encode-based comparison).
L2. ManifestRowsToRecords unconditionally writes DeleteWalsBefore — db/manifest_rows.cc
  • Issue: The function always writes a DeleteWalsBefore(db.min_log_number_to_keep) record, even when min_log_number_to_keep is 0. WriteCurrentStateToManifest also does this unconditionally (line 8183). Recovery handles DeleteWalsBefore(0) as a no-op, so this is safe.
  • Suggested fix: No change needed.

Cross-Component Analysis

Thread safety of wals_ access without mutex (DebugCheckRowsBeforeInstall):
Verified safe. wals_ is modified only in three places in version_set.cc:

  1. wals_.Reset() — during VersionSet close/reset (not concurrent with PMW)
  2. wals_.AddWals() — at line 6610, inside PMW after mu->Lock()
  3. wals_.DeleteWalsBefore() — at line 6612, inside PMW after mu->Lock()

Since only the PMW thread modifies wals_, and DebugCheckRowsBeforeInstall runs in the same thread before mu->Lock() (before the WAL edits are applied to wals_), reading wals_ without the mutex is safe.

Thread safety of first_cfd->current() for CF drop:
Verified safe. SetCurrent is called only from AppendVersion, which is called only from PMW after mu->Lock(). Since DebugCheckRowsBeforeInstall runs before mu->Lock(), the current Version cannot change.

marked_for_compaction race:
DB::SuggestCompactRange() sets marked_for_compaction on shared FileMetaData objects under the DB mutex. The PR's phase 1 check (without mutex) reads only file numbers and levels (immutable) for existing files, and full metadata only for newly added files (not shared). This correctly avoids the race.

ManifestRowsToRecords vs WriteCurrentStateToManifest compatibility:
Both produce records that recovery accepts. Key layout differences (all documented in PR):

  • DB id: ManifestRowsToRecords always writes it; WriteCurrentStateToManifest gates on option
  • min_log_number_to_keep: ManifestRowsToRecords puts it in the final DB record; WriteCurrentStateToManifest puts it in the default CF record
  • committed_options_file_number: ManifestRowsToRecords puts it in the final DB record; WriteCurrentStateToManifest writes a separate record

Recovery processes all fields by tag regardless of record grouping, so both layouts are correct.

Alternative execution contexts:

Context Does debug check execute? Safe?
Primary DB (ProcessManifestWrites) YES YES
ReadOnly DB NO (no PMW) N/A
Secondary/Follower (ReactiveVersionSet) NO (doesn't call PMW) N/A
CompactionService worker NO (doesn't write MANIFEST) N/A
DB::Open recovery First PMW call initializes rows YES

Positive Observations

  1. Excellent compile-time safety net: The ManifestRowFieldOfTag and ManifestRowFieldOfNewFileTag switch statements with no default case ensure that adding a new VersionEdit tag forces updating the row model. This is a clever use of -Wswitch -Werror.

  2. Well-designed two-phase check: Phase 1 (without mutex) checks everything it safely can, minimizing mutex-held work. Phase 2 (with mutex) handles only the fields that require the installed state.

  3. Thorough test coverage: ManifestRowsRoundTrip exercises all row fields including edge cases (UDT with timestamp removal, path_id, blob files with garbage, dropped blob files, committed options file number). ManifestRowChangesMatchVersions covers file add/delete, trivial move, compaction, blob garbage leading to blob file removal, atomic groups across CFs, WAL add/delete/rejection, options file, CF add/drop, and dummy writes.

  4. Clean separation of concerns: The row model is self-contained in manifest_rows.h/cc with no production code path dependency. The debug check hooks in version_set.cc are minimal and well-guarded.

  5. Intentional in-memory difference handling: The PR carefully documents and handles differences between the row state and in-memory state (next_file_number, max_column_family, committed_options_file_number, log_number of empty CFs, marked_for_compaction). The bounds checks in phase 2 are appropriately permissive.

  6. Good use of AddExistingFile for field copying: Using AddExistingFile to create file rows ensures that the row contains exactly the fields that a MANIFEST stores, automatically staying in sync with any new persisted FileMetaData fields.


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

@github-actions

github-actions Bot commented Nov 20, 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 38a29b8


Summary

Well-designed, carefully documented change that adds an internal MANIFEST row model with comprehensive debug-build verification. The code demonstrates strong awareness of concurrency constraints and correctly places all three hooks (fill, phase 1, phase 2) relative to the DB mutex boundaries. No high-severity findings.

High-severity findings (0):

No high-severity findings.

Full review (click to expand)

Findings

🟡 MEDIUM

M1. Fill step runs unnecessarily for skip_manifest_write paths — version_set.cc:6118 (new line)
  • Issue: The debug_manifest_rows_ fill step (GetManifestRows, which copies metadata of every live file) runs at the top of ProcessManifestWrites for every call, including skip_manifest_write paths where no phase 1 or phase 2 check will execute. This means the first call to ProcessManifestWrites, if it happens to be a skip_manifest_write call, does expensive work under the DB mutex that is never verified until the next real write.
  • Root cause: The fill step is placed before the skip_manifest_write check at line 6175.
  • Suggested fix: Guard the fill step with if (!skip_manifest_write), or move it into the else branch at line 6449. However, since this only triggers once (when debug_manifest_rows_ is null), the actual impact is minimal and bounded. This is a minor inefficiency in debug builds only.
M2. ManifestCfRow has no operator== — potential maintenance burden — manifest_rows.h
  • Issue: ManifestDbRow and ManifestBlobFileRow use = default for operator==, but ManifestCfRow uses a separate SameCfRow() function due to the special comparison semantics of compact_cursors (InternalKey comparison via encoding). This split creates a maintenance risk: a developer adding a new field to ManifestCfRow could forget to update SameCfRow() since there's no compiler-enforced exhaustiveness check (unlike the Tag switch in the test). The std::tie in SameCfRow lists fields explicitly and would silently miss a new one.
  • Root cause: InternalKey lacks a general-purpose operator== that handles the unset case.
  • Suggested fix: Consider adding a comment in ManifestCfRow noting that any new field must be added to SameCfRow(), or add a static_assert on sizeof to catch structural changes.

🟢 LOW / NIT

L1. ManifestRowsToRecords unconditionally emits DeleteWalsBefore(0) — manifest_rows.cc
  • Issue: When db.min_log_number_to_keep is 0 (the default), ManifestRowsToRecords still emits a DeleteWalsBefore(0) record. This is harmless (deleting WALs before number 0 is a no-op) but adds an unnecessary record to the MANIFEST output.
  • Suggested fix: Guard with if (db.min_log_number_to_keep != 0) for the DeleteWalsBefore record, consistent with how SetMinLogNumberToKeep is guarded in the DB edit at the end of the function.
L2. SameFileRow creates two temporary VersionEdits and encodes them for each file comparison — manifest_rows.cc
  • Issue: ManifestRowsEqual calls SameFileRow for every file, and each call constructs two VersionEdit objects, calls AddExistingFile, encodes both to strings, and compares. For a DB with many files, this is expensive. However, since this is used only in debug checks and tests, the performance impact is acceptable.
  • Suggested fix: No change needed given the debug-only usage, but document the O(files * encoding_cost) complexity.
L3. Test coverage: no negative test for BuildManifestRowChanges with invalid/corrupted edit — version_set_test.cc
  • Issue: The test ManifestRowChangesMatchVersions thoroughly covers the success path and WAL rejection, but doesn't test BuildManifestRowChanges with an edit that has inconsistent column family references or other edge cases that could exercise the assert(base_cf != old_rows.cfs.end()) guard.
  • Suggested fix: Consider adding a test that verifies the assert fires in debug builds when given inconsistent input, or at minimum documents that the function relies on ProcessManifestWrites to provide consistent input.
L4. ManifestRowFieldOfTag and ManifestRowFieldOfNewFileTag return const char* with no null check — version_set_test.cc
  • Issue: Both functions return nullptr after their switch statements (for unrecognized tags). The test EveryTagHasARowField only checks two specific tags, not exhaustively. The real check is at build time via -Wswitch, which is correct. However, if -Werror is not enabled on all build configurations, a missing case would only be caught at runtime.
  • Suggested fix: The -Wswitch + -Werror approach is standard for RocksDB. No change needed.

Cross-Component Analysis

Context Does code execute? Assumptions hold? Action needed?
ReactiveVersionSet / Secondary NO (doesn't run ProcessManifestWrites) N/A Safe
ReadOnly DB NO (doesn't write MANIFEST) N/A Safe
WritePreparedTxnDB YES (same ProcessManifestWrites) YES Safe
DB::Open (first PMW call) YES (fill step initializes rows) YES Safe
skip_manifest_write Partial (fill runs, no check) YES Minor waste (M1)
Concurrent SuggestCompactRange YES (can set marked_for_compaction) YES (phase 1 only reads number/level for shared files) Safe, documented

DB Mutex Analysis:

  • Fill step: mutex held. Copies all file metadata — expensive but bounded and infrequent (first call or after WAL rejection).
  • Phase 1: NO mutex. Safe because (1) only one thread runs PMW, (2) wals_ is only modified by PMW thread, (3) new Versions not yet visible to other threads, (4) shared FileMetaData only has number/level read (immutable fields).
  • Phase 2: mutex held. Cost is O(edits + live WALs + levels for added CF) — documented as lightweight.

WAL rejection recovery path: When BuildManifestRowChanges rejects a WAL edit, debug_manifest_rows_ is reset to null. The next PMW call refills from scratch. This is correct because the WAL edit rejection means ProcessManifestWrites will also fail to install (same WalSet logic), so the installed state hasn't changed.

Positive Observations

  • Excellent documentation: The header comments in manifest_rows.h and manifest_rows.cc are thorough, documenting invariants, thread safety, in-memory differences, and cost. The phase table in debug_manifest_rows_ is particularly helpful.
  • Build-time tag exhaustiveness: The ManifestRowFieldOfTag switch with no default case, combined with -Wswitch -Werror, ensures that adding a new VersionEdit tag forces updating the row model. This is a clever compile-time safety mechanism.
  • Careful thread safety reasoning: Phase 1 is carefully designed to read only immutable fields of shared FileMetaData objects, with detailed comments explaining why each access is safe without the mutex.
  • Correct WAL consistency: The use of WalSet copy in BuildManifestRowChanges mirrors the actual WAL application logic in ProcessManifestWrites, ensuring the debug check and the real logic agree.
  • Good test coverage: ManifestRowsRoundTrip covers all field types including UDT, path IDs, blob files, dropped CFs, WALs, and OPTIONS files. ManifestRowChangesMatchVersions covers file adds, trivial moves, compactions, blob garbage, atomic groups, WAL operations, CF add/drop, and the WAL rejection recovery path.
  • No release-build impact: All new code in ProcessManifestWrites is guarded by #ifndef NDEBUG. The new files (manifest_rows.h/cc) are compiled into the library but their functions are only called from debug hooks and tests.

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

xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 20, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
- Row model: `db/manifest_rows.h` defines `ManifestDbRow`, `ManifestCfRow`, `ManifestFileRow` (level plus the persisted `FileMetaData` fields), `ManifestBlobFileRow` and the WAL rows, grouped in `ManifestRows`. The overview comment at the top of the header lists the VersionEdit content that has no row field, and why.
- State to rows: `VersionSet::GetManifestRows()` reads the current state into rows.
- Rows to records: `ManifestRowsToRecords()` turns rows into full-state VersionEdit records that the existing recovery code replays. Its header comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`.
- Comparison: `ManifestRowsEqual()` compares two sets of rows and names the first difference. Its header comment says which rows it compares field by field and which through their encoding.
- Row changes: `BuildManifestRowChanges()` turns one MANIFEST write into a `ManifestRowChanges` (the new DB row, the rows to upsert and the keys to delete), and `ApplyManifestRowChanges()` applies it. The `BuildManifestRowChanges()` header comment holds all rules (DB row, prev log number, files, column family row, blob file rows, WAL rows) and the in-memory differences. `BaseReferencedVersionBuilder::version()` returns the base Version of a batch.
- Debug check: three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()` (fill, phase 1 without the DB mutex, phase 2 with the DB mutex held). The comment of `VersionSet::debug_manifest_rows_` has the timeline, a table of what each phase checks, and why phase 1 needs no DB mutex.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top and the row structs.
2. `db/version_set.h`: the `GetManifestRows()` declaration, then `db/manifest_rows.cc`: `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()` (state to rows).
3. `db/manifest_rows.cc`: `ManifestRowsToRecords()`, side by side with `VersionSet::WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. `db/manifest_rows.h`: `ManifestRowChanges` and `ApplyManifestRowChanges()`, then their code in `db/manifest_rows.cc`.
5. `db/manifest_rows.h`: `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, then its code; `db/version_builder.h`: `BaseReferencedVersionBuilder::version()`.
6. `db/version_set.h`: the `debug_manifest_rows_` comment with the phase table; `db/version_set.cc`: the three `#ifndef NDEBUG` hooks in `ProcessManifestWrites()`; then in `db/manifest_rows.cc` phase 1 (`DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()`) and phase 2 (`DebugCheckRowsAfterInstall()`, `VersionSet::SetManifestDbRowAndWals()`).
7. `db/version_set_test.cc`: `ManifestRowFieldOfTag()`, `ManifestRowFieldOfNewFileTag()`, `ManifestRowsRoundTrip`, then `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It does this with the DB mutex held. The first call is the first MANIFEST write of the VersionSet: often the one of `DB::Open()`, or a later write when `DB::Open()` writes no MANIFEST record.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 21, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
- Row model: `db/manifest_rows.h` defines `ManifestDbRow`, `ManifestCfRow`, `ManifestFileRow` (level plus the persisted `FileMetaData` fields), `ManifestBlobFileRow` and the WAL rows, grouped in `ManifestRows`. The overview comment at the top of the header lists the VersionEdit content that has no row field, and why.
- State to rows: `VersionSet::GetManifestRows()` reads the current state into rows.
- Rows to records: `ManifestRowsToRecords()` turns rows into full-state VersionEdit records that the existing recovery code replays. Its header comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`.
- Comparison: `ManifestRowsEqual()` compares two sets of rows and names the first difference. Its header comment says which rows it compares field by field and which through their encoding.
- Row changes: `BuildManifestRowChanges()` turns one MANIFEST write into a `ManifestRowChanges` (the new DB row, the rows to upsert and the keys to delete), and `ApplyManifestRowChanges()` applies it. The `BuildManifestRowChanges()` header comment holds all rules (DB row, prev log number, files, column family row, blob file rows, WAL rows) and the in-memory differences. `BaseReferencedVersionBuilder::version()` returns the base Version of a batch.
- Debug check: three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()` (fill, phase 1 without the DB mutex, phase 2 with the DB mutex held). The comment of `VersionSet::debug_manifest_rows_` has the timeline, a table of what each phase checks, and why phase 1 needs no DB mutex.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top and the row structs.
2. `db/version_set.h`: the `GetManifestRows()` declaration, then `db/manifest_rows.cc`: `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()` (state to rows).
3. `db/manifest_rows.cc`: `ManifestRowsToRecords()`, side by side with `VersionSet::WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. `db/manifest_rows.h`: `ManifestRowChanges` and `ApplyManifestRowChanges()`, then their code in `db/manifest_rows.cc`.
5. `db/manifest_rows.h`: `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, then its code; `db/version_builder.h`: `BaseReferencedVersionBuilder::version()`.
6. `db/version_set.h`: the `debug_manifest_rows_` comment with the phase table; `db/version_set.cc`: the three `#ifndef NDEBUG` hooks in `ProcessManifestWrites()`; then in `db/manifest_rows.cc` phase 1 (`DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()`) and phase 2 (`DebugCheckRowsAfterInstall()`, `VersionSet::SetManifestDbRowAndWals()`).
7. `db/version_set_test.cc`: `ManifestRowFieldOfTag()`, `ManifestRowFieldOfNewFileTag()`, `ManifestRowsRoundTrip`, then `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It does this with the DB mutex held. The first call is the first MANIFEST write of the VersionSet: often the one of `DB::Open()`, or a later write when `DB::Open()` writes no MANIFEST record.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 21, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
- Row model: `db/manifest_rows.h` defines `ManifestDbRow`, `ManifestCfRow`, `ManifestFileRow` (level plus the persisted `FileMetaData` fields), `ManifestBlobFileRow` and the WAL rows, grouped in `ManifestRows`. The overview comment at the top of the header lists the VersionEdit content that has no row field, and why.
- State to rows: `VersionSet::GetManifestRows()` reads the current state into rows.
- Rows to records: `ManifestRowsToRecords()` turns rows into full-state VersionEdit records that the existing recovery code replays. Its header comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`.
- Comparison: `ManifestRowsEqual()` compares two sets of rows and names the first difference. Its header comment says which rows it compares field by field and which through their encoding.
- Row changes: `BuildManifestRowChanges()` turns one MANIFEST write into a `ManifestRowChanges` (the new DB row, the rows to upsert and the keys to delete), and `ApplyManifestRowChanges()` applies it. The `BuildManifestRowChanges()` header comment holds all rules (DB row, prev log number, files, column family row, blob file rows, WAL rows) and the in-memory differences. `BaseReferencedVersionBuilder::version()` returns the base Version of a batch.
- Debug check: three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()` (fill, phase 1 without the DB mutex, phase 2 with the DB mutex held). The comment of `VersionSet::debug_manifest_rows_` has the timeline, a table of what each phase checks, and why phase 1 needs no DB mutex.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top and the row structs.
2. `db/version_set.h`: the `GetManifestRows()` declaration, then `db/manifest_rows.cc`: `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()` (state to rows).
3. `db/manifest_rows.cc`: `ManifestRowsToRecords()`, side by side with `VersionSet::WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. `db/manifest_rows.h`: `ManifestRowChanges` and `ApplyManifestRowChanges()`, then their code in `db/manifest_rows.cc`.
5. `db/manifest_rows.h`: `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, then its code; `db/version_builder.h`: `BaseReferencedVersionBuilder::version()`.
6. `db/version_set.h`: the `debug_manifest_rows_` comment with the phase table; `db/version_set.cc`: the three `#ifndef NDEBUG` hooks in `ProcessManifestWrites()`; then in `db/manifest_rows.cc` phase 1 (`DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()`) and phase 2 (`DebugCheckRowsAfterInstall()`, `VersionSet::SetManifestDbRowAndWals()`).
7. `db/version_set_test.cc`: `ManifestRowFieldOfTag()`, `ManifestRowFieldOfNewFileTag()`, `ManifestRowsRoundTrip`, then `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It does this with the DB mutex held. The first call is the first MANIFEST write of the VersionSet: often the one of `DB::Open()`, or a later write when `DB::Open()` writes no MANIFEST record.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 21, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
- Row model: `db/manifest_rows.h` defines `ManifestDbRow`, `ManifestCfRow`, `ManifestFileRow` (level plus the persisted `FileMetaData` fields), `ManifestBlobFileRow` and the WAL rows, grouped in `ManifestRows`. The overview comment at the top of the header lists the VersionEdit content that has no row field, and why.
- State to rows: `VersionSet::GetManifestRows()` reads the current state into rows.
- Rows to records: `ManifestRowsToRecords()` turns rows into full-state VersionEdit records that the existing recovery code replays. Its header comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`.
- Comparison: `ManifestRowsEqual()` compares two sets of rows and names the first difference. Its header comment says which rows it compares field by field and which through their encoding.
- Row changes: `BuildManifestRowChanges()` turns one MANIFEST write into a `ManifestRowChanges` (the new DB row, the rows to upsert and the keys to delete), and `ApplyManifestRowChanges()` applies it. The `BuildManifestRowChanges()` header comment holds all rules (DB row, prev log number, files, column family row, blob file rows, WAL rows) and the in-memory differences. `BaseReferencedVersionBuilder::version()` returns the base Version of a batch.
- Debug check: three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()` (fill, phase 1 without the DB mutex, phase 2 with the DB mutex held). The comment of `VersionSet::debug_manifest_rows_` has the timeline, a table of what each phase checks, and why phase 1 needs no DB mutex.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top and the row structs.
2. `db/version_set.h`: the `GetManifestRows()` declaration, then `db/manifest_rows.cc`: `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()` (state to rows).
3. `db/manifest_rows.cc`: `ManifestRowsToRecords()`, side by side with `VersionSet::WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. `db/manifest_rows.h`: `ManifestRowChanges` and `ApplyManifestRowChanges()`, then their code in `db/manifest_rows.cc`.
5. `db/manifest_rows.h`: `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, then its code; `db/version_builder.h`: `BaseReferencedVersionBuilder::version()`.
6. `db/version_set.h`: the `debug_manifest_rows_` comment with the phase table; `db/version_set.cc`: the three `#ifndef NDEBUG` hooks in `ProcessManifestWrites()`; then in `db/manifest_rows.cc` phase 1 (`DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()`) and phase 2 (`DebugCheckRowsAfterInstall()`, `VersionSet::SetManifestDbRowAndWals()`).
7. `db/version_set_test.cc`: `ManifestRowFieldOfTag()`, `ManifestRowFieldOfNewFileTag()`, `ManifestRowsRoundTrip`, then `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It does this with the DB mutex held. The first call is the first MANIFEST write of the VersionSet: often the one of `DB::Open()`, or a later write when `DB::Open()` writes no MANIFEST record.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 21, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
- Row model: `db/manifest_rows.h` defines `ManifestDbRow`, `ManifestCfRow`, `ManifestFileRow` (level plus the persisted `FileMetaData` fields), `ManifestBlobFileRow` and the WAL rows, grouped in `ManifestRows`. The overview comment at the top of the header lists the VersionEdit content that has no row field, and why.
- State to rows: `VersionSet::GetManifestRows()` reads the current state into rows.
- Rows to records: `ManifestRowsToRecords()` turns rows into full-state VersionEdit records that the existing recovery code replays. Its header comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`.
- Comparison: `ManifestRowsEqual()` compares two sets of rows and names the first difference. Its header comment says which rows it compares field by field and which through their encoding.
- Row changes: `BuildManifestRowChanges()` turns one MANIFEST write into a `ManifestRowChanges` (the new DB row, the rows to upsert and the keys to delete), and `ApplyManifestRowChanges()` applies it. The `BuildManifestRowChanges()` header comment holds all rules (DB row, prev log number, files, column family row, blob file rows, WAL rows) and the in-memory differences. `BaseReferencedVersionBuilder::version()` returns the base Version of a batch.
- Debug check: three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()` (fill, phase 1 without the DB mutex, phase 2 with the DB mutex held). The comment of `VersionSet::debug_manifest_rows_` has the timeline, a table of what each phase checks, and why phase 1 needs no DB mutex.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top and the row structs.
2. `db/version_set.h`: the `GetManifestRows()` declaration, then `db/manifest_rows.cc`: `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()` (state to rows).
3. `db/manifest_rows.cc`: `ManifestRowsToRecords()`, side by side with `VersionSet::WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. `db/manifest_rows.h`: `ManifestRowChanges` and `ApplyManifestRowChanges()`, then their code in `db/manifest_rows.cc`.
5. `db/manifest_rows.h`: `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, then its code; `db/version_builder.h`: `BaseReferencedVersionBuilder::version()`.
6. `db/version_set.h`: the `debug_manifest_rows_` comment with the phase table; `db/version_set.cc`: the three `#ifndef NDEBUG` hooks in `ProcessManifestWrites()`; then in `db/manifest_rows.cc` phase 1 (`DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()`) and phase 2 (`DebugCheckRowsAfterInstall()`, `VersionSet::SetManifestDbRowAndWals()`).
7. `db/version_set_test.cc`: `ManifestRowFieldOfTag()`, `ManifestRowFieldOfNewFileTag()`, `ManifestRowsRoundTrip`, then `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It does this with the DB mutex held. The first call is the first MANIFEST write of the VersionSet: often the one of `DB::Open()`, or a later write when `DB::Open()` writes no MANIFEST record.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 21, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
- Row model: `db/manifest_rows.h` defines `ManifestDbRow`, `ManifestCfRow`, `ManifestFileRow` (level plus the persisted `FileMetaData` fields), `ManifestBlobFileRow` and the WAL rows, grouped in `ManifestRows`. The overview comment at the top of the header lists the VersionEdit content that has no row field, and why.
- State to rows: `VersionSet::GetManifestRows()` reads the current state into rows.
- Rows to records: `ManifestRowsToRecords()` turns rows into full-state VersionEdit records that the existing recovery code replays. Its header comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`.
- Comparison: `ManifestRowsEqual()` compares two sets of rows and names the first difference. Its header comment says which rows it compares field by field and which through their encoding.
- Row changes: `BuildManifestRowChanges()` turns one MANIFEST write into a `ManifestRowChanges` (the new DB row, the rows to upsert and the keys to delete), and `ApplyManifestRowChanges()` applies it. The `BuildManifestRowChanges()` header comment holds all rules (DB row, prev log number, files, column family row, blob file rows, WAL rows) and the in-memory differences. `BaseReferencedVersionBuilder::version()` returns the base Version of a batch.
- Debug check: three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()` (fill, phase 1 without the DB mutex, phase 2 with the DB mutex held). The comment of `VersionSet::debug_manifest_rows_` has the timeline, a table of what each phase checks, and why phase 1 needs no DB mutex.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top and the row structs.
2. `db/version_set.h`: the `GetManifestRows()` declaration, then `db/manifest_rows.cc`: `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()` (state to rows).
3. `db/manifest_rows.cc`: `ManifestRowsToRecords()`, side by side with `VersionSet::WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. `db/manifest_rows.h`: `ManifestRowChanges` and `ApplyManifestRowChanges()`, then their code in `db/manifest_rows.cc`.
5. `db/manifest_rows.h`: `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, then its code; `db/version_builder.h`: `BaseReferencedVersionBuilder::version()`.
6. `db/version_set.h`: the `debug_manifest_rows_` comment with the phase table; `db/version_set.cc`: the three `#ifndef NDEBUG` hooks in `ProcessManifestWrites()`; then in `db/manifest_rows.cc` phase 1 (`DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()`) and phase 2 (`DebugCheckRowsAfterInstall()`, `VersionSet::SetManifestDbRowAndWals()`).
7. `db/version_set_test.cc`: `ManifestRowFieldOfTag()`, `ManifestRowFieldOfNewFileTag()`, `ManifestRowsRoundTrip`, then `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It does this with the DB mutex held. The first call is the first MANIFEST write of the VersionSet: often the one of `DB::Open()`, or a later write when `DB::Open()` writes no MANIFEST record.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match.

Differential Revision: D133208529
@github-actions

github-actions Bot commented Nov 21, 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 7f3d96c


Summary

Well-structured, carefully designed debug-only infrastructure for MANIFEST row change verification. The code is debug-only (#ifndef NDEBUG), introduces no behavior change in release builds, and the thread safety analysis is thorough and well-documented. The two-phase check design correctly separates expensive file-level verification (phase 1, without mutex) from lightweight state checks (phase 2, with mutex).

High-severity findings (0):

No high-severity findings.

Full review (click to expand)

Findings

🔴 HIGH

None.

🟡 MEDIUM

M1. BaseReferencedVersionBuilder::version() accessor is not guarded by NDEBUG -- db/version_builder.h:131
  • Issue: The new version() accessor exposes the private version_ member unconditionally, but its only caller is inside #ifndef NDEBUG in DebugCheckRowsBeforeInstall(). Exposing private state in release builds for a debug-only consumer widens the API surface unnecessarily.
  • Root cause: The accessor was added to the public section without an NDEBUG guard.
  • Suggested fix: Either wrap the accessor in #ifndef NDEBUG / #endif, or leave it as-is if there is an anticipated non-debug use case. The existing version_builder() accessor follows the same unconditional pattern, so this is a matter of preference -- but since version_builder() is used in release code (by ProcessManifestWrites itself) while version() currently is not, the guard would be more consistent.
M2. Fill step runs for skip_manifest_write (dummy) batches -- db/version_set.cc:6113-6119
  • Issue: The debug fill step (GetManifestRows) runs unconditionally at the top of ProcessManifestWrites, including for skip_manifest_write dummy edits. GetManifestRows copies the metadata of every live file under the DB mutex. For a dummy edit (e.g., DB::SetOptions()), this is wasted work in debug builds.
  • Root cause: The fill step is placed before the skip_manifest_write check.
  • Suggested fix: Move the fill inside the !skip_manifest_write branch, or document that filling on dummy writes is intentional (e.g., to establish the baseline before the first real write). The PR description mentions "It can also be a call that writes no MANIFEST record, such as the dummy edit of DB::SetOptions()" -- this appears intentional so the rows are ready for the first real write. If so, consider adding a brief inline comment.
M3. BuildManifestRowChanges scans all edits once per column family in batch_versions -- db/manifest_rows.cc (BuildManifestRowChanges, inner loop over edits)
  • Issue: For each ManifestBatchVersion, the code scans all edits to find the ones for that column family (the loop for (const VersionEdit* e : edits) inside the batch_versions loop). With N edits and M column families, this is O(N*M). In a large batch with many column families, this could be noticeable.
  • Root cause: No index or pre-grouping of edits by column family.
  • Suggested fix: This is debug-only code, so the performance impact is limited to debug builds. If it becomes a concern, pre-group edits by column family id before the batch_versions loop. Low priority given debug-only scope.

🟢 LOW / NIT

L1. SameCfRow does not compare compact_cursors size before element-wise comparison -- db/manifest_rows.cc (SameCfRow)
  • Issue: std::equal with the four-argument overload (begin/end of both ranges) correctly handles different sizes (C++14 and later), so this is not a bug. However, an explicit size check before the element-wise comparison would make the intent clearer and short-circuit on size mismatch.
  • Suggested fix: Optional clarity improvement: a.compact_cursors.size() == b.compact_cursors.size() && std::equal(...).
L2. Test uses LogAndApplyToDefaultCF for non-default-CF edits -- db/version_set_test.cc (ManifestRowChangesMatchVersions, WAL and OPTIONS edits)
  • Issue: WAL edits and OPTIONS edits are applied via LogAndApplyToDefaultCF which is correct since these are version-independent edits that go through the default CF's writer path. The LogAndApplyToCF helper correctly sets the column family on each edit before applying. Good separation.
  • Suggested fix: No fix needed. The test helpers are correct and well-designed.

Cross-Component Analysis

Context Does code execute? Assumptions hold? Action needed?
WritePreparedTxnDB YES (same ProcessManifestWrites) YES (debug hooks only read row state) None
ReadOnly DB NO (no MANIFEST writes) N/A None
Secondary/Follower NO (no MANIFEST writes) N/A None
CompactionService NO (remote worker uses own file) N/A None
User-defined timestamps YES YES (timestamp_size handled, EncodeTo uses ts_sz) None
MemPurge YES YES (no memtable interaction) None
FIFO/Universal compaction YES YES (compaction style irrelevant) None
BlobDB YES YES (blob file rows explicitly handled) None
Old snapshots YES YES (no snapshot state read) None

DB Mutex Analysis:

  • Fill step: mutex held, O(files). Matches existing WriteCurrentStateToManifest patterns. Debug-only.
  • Phase 1: no mutex. Thread safety well-documented. Only ProcessManifestWrites thread modifies wals_, debug_manifest_rows_, and installs Versions. Safe reads of immutable CFD fields and referenced Versions.
  • Phase 2: mutex held. O(edits + WALs + levels for CF add). No regression.
  • No mutex contention or hold-time impact in release builds.

Positive Observations

  • Excellent documentation: The header comments in manifest_rows.h are thorough, well-organized, and clearly explain the design rationale, known limitations, and in-memory differences.
  • Build-time tag coverage: The ManifestRowFieldOfTag switch with no default case ensures that adding a new VersionEdit tag forces the developer to update the row model. This is a clever defense against silent regressions.
  • Two-phase check design: Separating expensive file verification (phase 1) from lightweight state checks (phase 2) minimizes mutex hold time in debug builds.
  • Thread safety documentation: The debug_manifest_rows_ comment in version_set.h has an unusually thorough thread safety analysis, listing each object read in phase 1 and why it's safe.
  • Test quality: Both tests are well-designed. The round-trip test covers every field with non-default values and verifies that changes are detected. The row-changes test covers all MANIFEST write kinds and counts checks to ensure no write is missed.
  • Defensive coding: The assert(base_cf != old_rows.cfs.end()) with a fallback that keeps release builds from reading past the end is good defensive practice.

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

@xingbowang
xingbowang force-pushed the export-D133208529 branch 2 times, most recently from 3a5eca0 to 5c9f5f4 Compare November 22, 2026 13:54
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 22, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. Each step of phase 2 is a few lookups. Phase 2 also erases the debug rows of a dropped column family, because no later MANIFEST write names it.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Symbols:
- Row model: `db/manifest_rows.h` defines `ManifestDbRow`, `ManifestCfRow`, `ManifestFileRow` (level plus the persisted `FileMetaData` fields), `ManifestBlobFileRow` and the WAL rows, grouped in `ManifestRows`. The overview comment at the top of the header lists the VersionEdit content that has no row field, and why.
- State to rows: `VersionSet::GetManifestRows()` reads the current state into rows.
- Rows to records: `ManifestRowsToRecords()` turns rows into full-state VersionEdit records that the existing recovery code replays. Its header comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`.
- Comparison: `ManifestRowsEqual()` compares two sets of rows and names the first difference. Its header comment says which rows it compares field by field and which through their encoding.
- Row changes: `BuildManifestRowChanges()` turns one MANIFEST write into a `ManifestRowChanges` (the new DB row, the rows to upsert and the keys to delete; an upsert adds a row or replaces the row with the same key), and `ApplyManifestRowChanges()` applies it. The `BuildManifestRowChanges()` header comment holds all rules (DB row, prev log number, files, column family row, blob file rows, WAL rows). `BaseReferencedVersionBuilder::version()` returns the base Version that the edits of one column family in a batch are applied to.
- Debug check: `MakeManifestBatchVersions()` pairs each new Version with its base Version for phase 1. Three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()` run the check: fill, phase 1 without the DB mutex, and phase 2 with the DB mutex held. The comment of `VersionSet::debug_manifest_rows_` has the timeline, a table of what each phase checks, and why phase 1 needs no DB mutex.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It does this with the DB mutex held. The first call is the first `LogAndApply()` of the VersionSet. This is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`, because the drop edit lists no deleted files and the drop installs no new Version. The files are deleted later, when the last reference to the column family is released, and no MANIFEST write records that. `ManifestRowsToRecords()` skips these rows, so recovery does not see them. The debug check erases them from its own copy.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top and the row structs.
2. `db/version_set.h`: the `GetManifestRows()` declaration, then `db/manifest_rows.cc`: `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()` (state to rows).
3. `db/manifest_rows.cc`: `ManifestRowsToRecords()`, side by side with `VersionSet::WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. `db/manifest_rows.h`: `ManifestRowChanges` and `ApplyManifestRowChanges()`, then their code in `db/manifest_rows.cc`.
5. `db/manifest_rows.h`: `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, then its code; `db/version_builder.h`: `BaseReferencedVersionBuilder::version()`.
6. `db/version_set.h`: the `debug_manifest_rows_` comment with the phase table; `db/version_set.cc`: the three `#ifndef NDEBUG` hooks in `ProcessManifestWrites()`; then in `db/manifest_rows.cc` phase 1 (`MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()`) and phase 2 (`DebugCheckRowsAfterInstall()`, `VersionSet::SetManifestDbRowAndWals()`).
7. `db/version_set_test.cc`: `ManifestRowFieldOfTag()`, `ManifestRowFieldOfNewFileTag()`, `ManifestRowsRoundTrip`, then `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 22, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. Each step of phase 2 is a few lookups. Phase 2 also erases the debug rows of a dropped column family, because no later MANIFEST write names it.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Symbols:
- Row model: `db/manifest_rows.h` defines `ManifestDbRow`, `ManifestCfRow`, `ManifestFileRow` (level plus the persisted `FileMetaData` fields), `ManifestBlobFileRow` and the WAL rows, grouped in `ManifestRows`. The overview comment at the top of the header lists the VersionEdit content that has no row field, and why.
- State to rows: `VersionSet::GetManifestRows()` reads the current state into rows.
- Rows to records: `ManifestRowsToRecords()` turns rows into full-state VersionEdit records that the existing recovery code replays. Its header comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`.
- Comparison: `ManifestRowsEqual()` compares two sets of rows and names the first difference. Its header comment says which rows it compares field by field and which through their encoding.
- Row changes: `BuildManifestRowChanges()` turns one MANIFEST write into a `ManifestRowChanges` (the new DB row, the rows to upsert and the keys to delete; an upsert adds a row or replaces the row with the same key), and `ApplyManifestRowChanges()` applies it. The `BuildManifestRowChanges()` header comment holds all rules (DB row, prev log number, files, column family row, blob file rows, WAL rows). `BaseReferencedVersionBuilder::version()` returns the base Version that the edits of one column family in a batch are applied to.
- Debug check: `MakeManifestBatchVersions()` pairs each new Version with its base Version for phase 1. Three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()` run the check: fill, phase 1 without the DB mutex, and phase 2 with the DB mutex held. The comment of `VersionSet::debug_manifest_rows_` has the timeline, a table of what each phase checks, and why phase 1 needs no DB mutex.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It does this with the DB mutex held. The first call is the first `LogAndApply()` of the VersionSet. This is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`, because the drop edit lists no deleted files and the drop installs no new Version. The files are deleted later, when the last reference to the column family is released, and no MANIFEST write records that. `ManifestRowsToRecords()` skips these rows, so recovery does not see them. The debug check erases them from its own copy.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top and the row structs.
2. `db/version_set.h`: the `GetManifestRows()` declaration, then `db/manifest_rows.cc`: `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()` (state to rows).
3. `db/manifest_rows.cc`: `ManifestRowsToRecords()`, side by side with `VersionSet::WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. `db/manifest_rows.h`: `ManifestRowChanges` and `ApplyManifestRowChanges()`, then their code in `db/manifest_rows.cc`.
5. `db/manifest_rows.h`: `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, then its code; `db/version_builder.h`: `BaseReferencedVersionBuilder::version()`.
6. `db/version_set.h`: the `debug_manifest_rows_` comment with the phase table; `db/version_set.cc`: the three `#ifndef NDEBUG` hooks in `ProcessManifestWrites()`; then in `db/manifest_rows.cc` phase 1 (`MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()`) and phase 2 (`DebugCheckRowsAfterInstall()`, `VersionSet::SetManifestDbRowAndWals()`).
7. `db/version_set_test.cc`: `ManifestRowFieldOfTag()`, `ManifestRowFieldOfNewFileTag()`, `ManifestRowsRoundTrip`, then `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 22, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. Each step of phase 2 is a few lookups. Phase 2 also erases the debug rows of a dropped column family, because no later MANIFEST write names it.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Symbols:
- Row model: `db/manifest_rows.h` defines `ManifestDbRow`, `ManifestCfRow`, `ManifestFileRow` (level plus the persisted `FileMetaData` fields), `ManifestBlobFileRow` and the WAL rows, grouped in `ManifestRows`. The overview comment at the top of the header lists the VersionEdit content that has no row field, and why.
- State to rows: `VersionSet::GetManifestRows()` reads the current state into rows.
- Rows to records: `ManifestRowsToRecords()` turns rows into full-state VersionEdit records that the existing recovery code replays. Its header comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`.
- Comparison: `ManifestRowsEqual()` compares two sets of rows and names the first difference. Its header comment says which rows it compares field by field and which through their encoding.
- Row changes: `BuildManifestRowChanges()` turns one MANIFEST write into a `ManifestRowChanges` (the new DB row, the rows to upsert and the keys to delete; an upsert adds a row or replaces the row with the same key), and `ApplyManifestRowChanges()` applies it. The `BuildManifestRowChanges()` header comment holds all rules (DB row, prev log number, files, column family row, blob file rows, WAL rows). `BaseReferencedVersionBuilder::version()` returns the base Version that the edits of one column family in a batch are applied to.
- Debug check: `MakeManifestBatchVersions()` pairs each new Version with its base Version for phase 1. Three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()` run the check: fill, phase 1 without the DB mutex, and phase 2 with the DB mutex held. The comment of `VersionSet::debug_manifest_rows_` has the timeline, a table of what each phase checks, and why phase 1 needs no DB mutex.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It does this with the DB mutex held. The first call is the first `LogAndApply()` of the VersionSet. This is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`, because the drop edit lists no deleted files and the drop installs no new Version. The files are deleted later, when the last reference to the column family is released, and no MANIFEST write records that. `ManifestRowsToRecords()` skips these rows, so recovery does not see them. The debug check erases them from its own copy.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top and the row structs.
2. `db/version_set.h`: the `GetManifestRows()` declaration, then `db/manifest_rows.cc`: `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()` (state to rows).
3. `db/manifest_rows.cc`: `ManifestRowsToRecords()`, side by side with `VersionSet::WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. `db/manifest_rows.h`: `ManifestRowChanges` and `ApplyManifestRowChanges()`, then their code in `db/manifest_rows.cc`.
5. `db/manifest_rows.h`: `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, then its code; `db/version_builder.h`: `BaseReferencedVersionBuilder::version()`.
6. `db/version_set.h`: the `debug_manifest_rows_` comment with the phase table; `db/version_set.cc`: the three `#ifndef NDEBUG` hooks in `ProcessManifestWrites()`; then in `db/manifest_rows.cc` phase 1 (`MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()`) and phase 2 (`DebugCheckRowsAfterInstall()`, `VersionSet::SetManifestDbRowAndWals()`).
7. `db/version_set_test.cc`: `ManifestRowFieldOfTag()`, `ManifestRowFieldOfNewFileTag()`, `ManifestRowsRoundTrip`, then `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 22, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. Each step of phase 2 is a few lookups. Phase 2 also erases the debug rows of a dropped column family, because no later MANIFEST write names it.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Symbols:
- Row model: `db/manifest_rows.h` defines `ManifestDbRow`, `ManifestCfRow`, `ManifestFileRow` (level plus the persisted `FileMetaData` fields), `ManifestBlobFileRow` and the WAL rows, grouped in `ManifestRows`. The overview comment at the top of the header lists the VersionEdit content that has no row field, and why.
- State to rows: `VersionSet::GetManifestRows()` reads the current state into rows.
- Rows to records: `ManifestRowsToRecords()` turns rows into full-state VersionEdit records that the existing recovery code replays. Its header comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`.
- Comparison: `ManifestRowsEqual()` compares two sets of rows and names the first difference. Its header comment says which rows it compares field by field and which through their encoding.
- Row changes: `BuildManifestRowChanges()` turns one MANIFEST write into a `ManifestRowChanges` (the new DB row, the rows to upsert and the keys to delete; an upsert adds a row or replaces the row with the same key), and `ApplyManifestRowChanges()` applies it. The `BuildManifestRowChanges()` header comment holds all rules (DB row, prev log number, files, column family row, blob file rows, WAL rows). `BaseReferencedVersionBuilder::version()` returns the base Version that the edits of one column family in a batch are applied to.
- Debug check: `MakeManifestBatchVersions()` pairs each new Version with its base Version for phase 1. Three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()` run the check: fill, phase 1 without the DB mutex, and phase 2 with the DB mutex held. The comment of `VersionSet::debug_manifest_rows_` has the timeline, a table of what each phase checks, and why phase 1 needs no DB mutex.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It does this with the DB mutex held. The first call is the first `LogAndApply()` of the VersionSet. This is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`, because the drop edit lists no deleted files and the drop installs no new Version. The files are deleted later, when the last reference to the column family is released, and no MANIFEST write records that. `ManifestRowsToRecords()` skips these rows, so recovery does not see them. The debug check erases them from its own copy.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top and the row structs.
2. `db/version_set.h`: the `GetManifestRows()` declaration, then `db/manifest_rows.cc`: `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()` (state to rows).
3. `db/manifest_rows.cc`: `ManifestRowsToRecords()`, side by side with `VersionSet::WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. `db/manifest_rows.h`: `ManifestRowChanges` and `ApplyManifestRowChanges()`, then their code in `db/manifest_rows.cc`.
5. `db/manifest_rows.h`: `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, then its code; `db/version_builder.h`: `BaseReferencedVersionBuilder::version()`.
6. `db/version_set.h`: the `debug_manifest_rows_` comment with the phase table; `db/version_set.cc`: the three `#ifndef NDEBUG` hooks in `ProcessManifestWrites()`; then in `db/manifest_rows.cc` phase 1 (`MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()`) and phase 2 (`DebugCheckRowsAfterInstall()`, `VersionSet::SetManifestDbRowAndWals()`).
7. `db/version_set_test.cc`: `ManifestRowFieldOfTag()`, `ManifestRowFieldOfNewFileTag()`, `ManifestRowsRoundTrip`, then `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 22, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. Each step of phase 2 is a few lookups. Phase 2 also erases the debug rows of a dropped column family, because no later MANIFEST write names it.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Symbols:
- Row model: `db/manifest_rows.h` defines `ManifestDbRow`, `ManifestCfRow`, `ManifestFileRow` (level plus the persisted `FileMetaData` fields), `ManifestBlobFileRow` and the WAL rows, grouped in `ManifestRows`. The overview comment at the top of the header lists the VersionEdit content that has no row field, and why.
- State to rows: `VersionSet::GetManifestRows()` reads the current state into rows.
- Rows to records: `ManifestRowsToRecords()` turns rows into full-state VersionEdit records that the existing recovery code replays. Its header comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`.
- Comparison: `ManifestRowsEqual()` compares two sets of rows and names the first difference. Its header comment says which rows it compares field by field and which through their encoding.
- Row changes: `BuildManifestRowChanges()` turns one MANIFEST write into a `ManifestRowChanges` (the new DB row, the rows to upsert and the keys to delete; an upsert adds a row or replaces the row with the same key), and `ApplyManifestRowChanges()` applies it. The `BuildManifestRowChanges()` header comment holds all rules (DB row, prev log number, files, column family row, blob file rows, WAL rows). `BaseReferencedVersionBuilder::version()` returns the base Version that the edits of one column family in a batch are applied to.
- Debug check: `MakeManifestBatchVersions()` pairs each new Version with its base Version for phase 1. Three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()` run the check: fill, phase 1 without the DB mutex, and phase 2 with the DB mutex held. The comment of `VersionSet::debug_manifest_rows_` has the timeline, a table of what each phase checks, and why phase 1 needs no DB mutex.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It does this with the DB mutex held. The first call is the first `LogAndApply()` of the VersionSet. This is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`, because the drop edit lists no deleted files and the drop installs no new Version. The files are deleted later, when the last reference to the column family is released, and no MANIFEST write records that. `ManifestRowsToRecords()` skips these rows, so recovery does not see them. The debug check erases them from its own copy.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top and the row structs.
2. `db/version_set.h`: the `GetManifestRows()` declaration, then `db/manifest_rows.cc`: `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()` (state to rows).
3. `db/manifest_rows.cc`: `ManifestRowsToRecords()`, side by side with `VersionSet::WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. `db/manifest_rows.h`: `ManifestRowChanges` and `ApplyManifestRowChanges()`, then their code in `db/manifest_rows.cc`.
5. `db/manifest_rows.h`: `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, then its code; `db/version_builder.h`: `BaseReferencedVersionBuilder::version()`.
6. `db/version_set.h`: the `debug_manifest_rows_` comment with the phase table; `db/version_set.cc`: the three `#ifndef NDEBUG` hooks in `ProcessManifestWrites()`; then in `db/manifest_rows.cc` phase 1 (`MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()`) and phase 2 (`DebugCheckRowsAfterInstall()`, `VersionSet::SetManifestDbRowAndWals()`).
7. `db/version_set_test.cc`: `ManifestRowFieldOfTag()`, `ManifestRowFieldOfNewFileTag()`, `ManifestRowsRoundTrip`, then `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 22, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. Each step of phase 2 is a few lookups. Phase 2 also erases the debug rows of a dropped column family, because no later MANIFEST write names it.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Symbols:
- Row model: `db/manifest_rows.h` defines `ManifestDbRow`, `ManifestCfRow`, `ManifestFileRow` (level plus the persisted `FileMetaData` fields), `ManifestBlobFileRow` and the WAL rows, grouped in `ManifestRows`. The overview comment at the top of the header lists the VersionEdit content that has no row field, and why.
- State to rows: `VersionSet::GetManifestRows()` reads the current state into rows.
- Rows to records: `ManifestRowsToRecords()` turns rows into full-state VersionEdit records that the existing recovery code replays. Its header comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`.
- Comparison: `ManifestRowsEqual()` compares two sets of rows and names the first difference. Its header comment says which rows it compares field by field and which through their encoding.
- Row changes: `BuildManifestRowChanges()` turns one MANIFEST write into a `ManifestRowChanges` (the new DB row, the rows to upsert and the keys to delete; an upsert adds a row or replaces the row with the same key), and `ApplyManifestRowChanges()` applies it. The `BuildManifestRowChanges()` header comment holds all rules (DB row, prev log number, files, column family row, blob file rows, WAL rows). `BaseReferencedVersionBuilder::version()` returns the base Version that the edits of one column family in a batch are applied to.
- Debug check: `MakeManifestBatchVersions()` pairs each new Version with its base Version for phase 1. Three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()` run the check: fill, phase 1 without the DB mutex, and phase 2 with the DB mutex held. The comment of `VersionSet::debug_manifest_rows_` has the timeline, a table of what each phase checks, and why phase 1 needs no DB mutex.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It does this with the DB mutex held. The first call is the first `LogAndApply()` of the VersionSet. This is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`, because the drop edit lists no deleted files and the drop installs no new Version. The files are deleted later, when the last reference to the column family is released, and no MANIFEST write records that. `ManifestRowsToRecords()` skips these rows, so recovery does not see them. The debug check erases them from its own copy.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top and the row structs.
2. `db/version_set.h`: the `GetManifestRows()` declaration, then `db/manifest_rows.cc`: `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()` (state to rows).
3. `db/manifest_rows.cc`: `ManifestRowsToRecords()`, side by side with `VersionSet::WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. `db/manifest_rows.h`: `ManifestRowChanges` and `ApplyManifestRowChanges()`, then their code in `db/manifest_rows.cc`.
5. `db/manifest_rows.h`: `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, then its code; `db/version_builder.h`: `BaseReferencedVersionBuilder::version()`.
6. `db/version_set.h`: the `debug_manifest_rows_` comment with the phase table; `db/version_set.cc`: the three `#ifndef NDEBUG` hooks in `ProcessManifestWrites()`; then in `db/manifest_rows.cc` phase 1 (`MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()`) and phase 2 (`DebugCheckRowsAfterInstall()`, `VersionSet::SetManifestDbRowAndWals()`).
7. `db/version_set_test.cc`: `ManifestRowFieldOfTag()`, `ManifestRowFieldOfNewFileTag()`, `ManifestRowsRoundTrip`, then `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
@github-actions

github-actions Bot commented Nov 22, 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 5c9f5f4


Summary

Well-designed and carefully documented PR that adds an internal MANIFEST row model with comprehensive debug-time verification. The two-phase check design (phase 1 without DB mutex, phase 2 with mutex) is sound, and the thread safety reasoning is thorough. The code follows RocksDB conventions, has zero cost in release builds, and includes strong test coverage via both explicit tests and implicit verification on every ProcessManifestWrites call in debug builds.

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

Full review (click to expand)

Findings

🔴 HIGH

No high-severity findings.

🟡 MEDIUM

M1. prev_log_number mismatch between BuildManifestRowChanges and ProcessManifestWrites when first writer's CF is dropped — db/manifest_rows.cc
  • Issue: BuildManifestRowChanges takes edits.front()->GetPrevLogNumber() as the prev log number. ProcessManifestWrites takes first_writer.edit_list.front()->GetPrevLogNumber(). When the first writer's column family is dropped, its edits are excluded from batch_edits (the IsDropped() check at version_set.cc:6200), so edits.front() in BuildManifestRowChanges is a different edit than first_writer.edit_list.front(). The PR description acknowledges this case and claims both values are 0 in this scenario. The reasoning appears correct (a dropped CF's edit skips LogAndApplyHelper, keeping the default 0, and the in-memory value was set to 0 by the drop). However, this is a subtle invariant that relies on multiple interacting behaviors. If this reasoning ever breaks, the debug check would fire (by design), so the risk is contained.
  • Root cause: The function receives edits (batch_edits) rather than the first writer's raw edit list, so it cannot directly access the same edit that ProcessManifestWrites uses.
  • Suggested fix: Consider adding a comment in DebugCheckRowsBeforeInstall documenting this invariant near the BuildManifestRowChanges call, or pass the prev_log_number explicitly rather than deriving it from edits.front().
M2. AddExistingFile copies marked_for_compaction which can be set concurrently — db/manifest_rows.cc:68
  • Issue: MakeFileRow calls edit.AddExistingFile(level, f, 0), and AddExistingFile (version_edit.cc:206) reads f.marked_for_compaction. This field can be set concurrently by DB::SuggestCompactRange(). In phase 1 (without DB mutex), AssertCfRowsMatchVersion calls MakeFileRow for files in changes.file_upserts (newly added files from the current write). These are new FileMetaData objects not yet visible to other threads, so the concurrent access concern doesn't apply to them. For the fill step (GetManifestRows), it runs under the DB mutex. So in practice this is safe, but the reasoning is non-obvious.
  • Suggested fix: Add a brief comment in MakeFileRow noting that this is safe because it's only called on newly-created FileMetaData objects in phase 1, and under the DB mutex in the fill step.
M3. GetManifestRows() placed in public section of VersionSet — db/version_set.h
  • Issue: GetManifestRows() is added to the public section of VersionSet. It copies metadata of every live file under the DB mutex and is documented as "meant for tests, debug checks and tools, not for the write path." Given its cost and intended usage, it may be more appropriate in the protected section or with a TEST_ prefix.
  • Suggested fix: Consider moving to the protected section or renaming to TEST_GetManifestRows, similar to the adjacent TEST_CreateAndAppendVersion pattern.

🟢 LOW / NIT

L1. ManifestRowsToRecords unconditionally emits DeleteWalsBefore record — db/manifest_rows.cc
  • Issue: Always emits a DeleteWalsBefore(db.min_log_number_to_keep) record even when min_log_number_to_keep is 0. While recovery handles this correctly (deleting WALs before number 0 is a no-op), it generates an unnecessary record.
  • Suggested fix: Consider guarding with if (db.min_log_number_to_keep > 0), matching how the DB edit at the end conditionally sets it.
L2. SameFileRow serializes both rows to compare them — db/manifest_rows.cc
  • Issue: Serializes two VersionEdit objects and compares encoded strings. Correct and automatically catches new persisted fields, but expensive. Since this only runs in debug builds, the cost is acceptable, and the comment explains the design rationale well.
L3. std::map usage for debug-only data — db/manifest_rows.h
  • Issue: With 100K+ SST files, the per-node allocation overhead of std::map is significant. Since this is debug-only and ordered iteration enables deterministic output, this is acceptable.

Cross-Component Analysis

Context Affected? Safe? Notes
WritePreparedTxnDB Yes Yes Debug check only reads MANIFEST-level metadata
ReadOnly DB / Secondary No N/A Does not call ProcessManifestWrites
CompactionService No N/A Workers don't write DB MANIFEST
User-defined timestamps Yes Yes Tested in ManifestRowsRoundTrip
BlobDB Yes Yes Blob file rows explicitly handled
FIFO / Universal compaction Yes Yes Same MANIFEST write path

DB Mutex verification:

  • Phase 2 work under mutex: SetManifestDbRowAndWals (O(1) + O(live WALs) copy) + O(edits) lookups. Well bounded.
  • Fill step under mutex: copies all file metadata. Runs only on first call or after WAL rejection.
  • wals_ modification sites verified: all in ProcessManifestWrites thread or recovery/reset (not concurrent).

Positive Observations

  1. Build-time safety net: ManifestRowFieldOfTag switch with no default ensures adding a new VersionEdit tag without updating the row model causes a build failure.
  2. Zero release-build cost: All debug check code properly guarded by #ifndef NDEBUG.
  3. Comprehensive implicit test coverage: Every existing test that calls ProcessManifestWrites in debug builds exercises this code.
  4. Thorough documentation: Header comments in manifest_rows.h are well-structured, documenting what's stored, what's not, in-memory differences, and thread safety reasoning.

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

xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 23, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
@github-actions

github-actions Bot commented Nov 23, 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 4204215


Summary

Well-designed feature that adds a structured row model for MANIFEST data with thorough debug-only verification. The code is carefully structured to minimize DB mutex impact (heavy work in phase 1 without mutex, lightweight phase 2 with mutex). Thread safety analysis is convincing. Documentation is excellent.

High-severity findings (0):

No high-severity findings.

Full review (click to expand)

Findings

🟡 MEDIUM

M1. marked_for_compaction data race in MakeFileRow via AddExistingFile -- db/manifest_rows.cc:69
  • Issue: MakeFileRow() calls AddExistingFile() which reads f.marked_for_compaction (version_edit.cc:206). marked_for_compaction is a non-atomic bool that SuggestCompactRange() can set on files in the current Version without holding the DB mutex (db_impl_experimental.cc:44). Phase 1 calls MakeFileRow on files from v.new_version (not installed, safe) and from the edits' new files (VersionEdit-local copies, safe). So in practice the race does not manifest with current callers. However, if future code calls MakeFileRow on a live Version's FileMetaData without the mutex, it would be a TSAN violation.
  • Root cause: AddExistingFile copies marked_for_compaction, which is documented as mutable by other threads.
  • Suggested fix: Acceptable as-is since all current callers pass safe copies. Consider adding a comment noting that MakeFileRow must not be called on shared FileMetaData objects without the DB mutex, to guard future callers.
M2. Fill step cost under DB mutex -- db/version_set.cc:6118 (from diff)
  • Issue: The fill step calls GetManifestRows() under the DB mutex, copying metadata of every live SST file, blob file, and WAL. For a DB with 100K SST files, this is O(100K) FileMetaData copies with string fields. It runs only on the first call and after a WAL rejection, but the first call is typically during DB::Open().
  • Root cause: Intentional design -- the fill step needs a consistent snapshot under mutex.
  • Suggested fix: Acceptable for debug builds. The PR description correctly documents this cost.
M3. Release-build compiled but unused functions -- db/manifest_rows.cc
  • Issue: GetManifestRows(), BuildManifestRowChanges(), ApplyManifestRowChanges(), ManifestRowsToRecords(), ManifestRowsEqual() etc. are compiled in release builds with no release-build caller yet. The PR description explains this is intentional for the planned external metadata store.
  • Suggested fix: Acceptable as-is. Tests exercise them, and they will gain release callers in a follow-up.

🟢 LOW / NIT

L1. SameFileRow comparison via encoding -- db/manifest_rows.cc:~580
  • Issue: SameFileRow creates two VersionEdit objects, encodes both to strings, then compares. Multiple allocations per comparison. The design trade-off (automatic coverage of new fields) is well-documented and reasonable for debug/test code.
L2. BaseReferencedVersionBuilder::version() compiled in release -- db/version_builder.h:131
  • Issue: The accessor is not in #ifndef NDEBUG, but its only caller is debug-only. Inline and zero-cost if unused.
L3. ManifestRowsToRecords always emits DeleteWalsBefore even when min_log_number_to_keep is 0 -- db/manifest_rows.cc:~390
  • Issue: Unconditionally emits a no-op DeleteWalsBefore(0) record. Correct but slightly wasteful.

Cross-Component Analysis

Context Executes? Safe? Action
WritePreparedTxnDB YES (debug) YES -- rows model MANIFEST, not txn visibility None
ReadOnly/Secondary DB NO -- no ProcessManifestWrites N/A None
User-defined timestamps YES -- tested YES -- timestamp_size plumbed correctly None
BlobDB YES -- tested YES None
Concurrent writers YES -- single PMW thread YES None
FIFO/Universal compaction YES (debug) YES -- compaction-style independent None

Positive Observations

  • Excellent documentation: Thorough header comments including "In-memory differences", row layout diagram, and per-function rules.
  • Sound two-phase design: Phase 1 (heavy, no mutex) + phase 2 (lightweight, with mutex) minimizes mutex hold time.
  • Comprehensive tests: Round-trip test covers all fields (UDT, path IDs, blob files, dropped CFs, compact cursors, OPTIONS). Match test covers all edit types including atomic groups, WAL rejection, CF add/drop.
  • Tag checklist mechanism: -Wswitch based ManifestRowFieldOfTag ensures new tags are accounted for.
  • Thread safety documentation: Explicit per-object justification for phase 1 safety.
  • Build systems: All three (Make, CMake, BUCK) correctly updated.

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

xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 23, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 23, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 23, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 23, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
@github-actions

github-actions Bot commented Nov 23, 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 efaaba0


Summary

Well-structured PR that adds an internal MANIFEST row model with comprehensive debug checks and no release-build impact. The two-phase debug check design correctly accounts for mutex boundaries, the ManifestRowFieldOfTag switch pattern is a clever build-time guardrail, and the round-trip test provides strong coverage. The code is thorough and well-documented.

High-severity findings (0):

No high-severity findings.

Full review (click to expand)

Findings

🔴 HIGH

No high-severity findings.

🟡 MEDIUM

M1. marked_for_compaction race analysis in MakeFileRow — db/manifest_rows.cc
  • Issue: MakeFileRow calls AddExistingFile, which copies f.marked_for_compaction (version_edit.cc:206). marked_for_compaction can be set by DB::SuggestCompactRange() from any thread without the DB mutex (version_set.h:621). A torn read is theoretically possible when MakeFileRow runs without the mutex.
  • Root cause: marked_for_compaction is a plain bool, not atomic. The comment at version_edit.h:309 says "These values can mutate, but they can only be read or written from single-threaded LogAndApply thread" — but SuggestCompactRange violates this for marked_for_compaction.
  • Assessment: After tracing all call sites, this is not a real race in the new code. MakeFileRow is called: (1) in SetManifestCfRows during the fill step under the DB mutex; (2) in BuildManifestRowChanges on files from e->GetNewFiles() which are VersionEdit-owned copies; (3) in AssertCfRowsMatchVersion on the new Version's files, but only for files in changes.file_upserts (newly created FileMetaData objects, not shared). Existing files are compared only by number and level. The thread safety argument is valid but subtle.
  • Suggested fix: No code change needed. Consider adding a brief note in the AssertCfRowsMatchVersion comment clarifying why reading all fields of upserted files is safe (they are new objects).
M2. Memory cost of debug_manifest_rows_ for large DBs — db/version_set.h
  • Issue: debug_manifest_rows_ holds a copy of all file metadata for every live file. For a DB with 100K SST files, this could be ~100MB+ of additional debug-only memory. The PR mentions "about as much memory as the FileMetaData objects" in manifest_rows.h but doesn't quantify the absolute cost.
  • Root cause: Each ManifestFileRow contains a full FileMetaData copy (including strings for checksum, timestamps, file_open_metadata) plus std::map node overhead (~48 bytes per node).
  • Suggested fix: The documentation already mentions this. For large-scale debug testing, developers should be aware of the overhead.

🟢 LOW / NIT

L1. SameFileRow creates two temporary VersionEdits — db/manifest_rows.cc
  • Issue: SameFileRow creates two VersionEdit objects, encodes both, and compares strings. This is deliberate — it auto-detects new persisted fields without code changes — but it's relatively expensive per comparison.
  • Mitigating factors: Only used in debug checks, never on the hot path. The design is intentional and documented.
L2. BaseReferencedVersionBuilder::version() broadens internal API — db/version_builder.h
  • Issue: New public accessor exposes the private version_ member. This is an internal header, so no public API concern. Consistent with the existing version_builder() accessor pattern.
  • Suggested fix: No change needed.

Cross-Component Analysis

Context Executes? Safe? Notes
WritePreparedTxnDB YES YES Debug check only compares metadata, not key visibility
ReadOnly DB / SecondaryInstance NO N/A They don't write MANIFEST
Recovery NO N/A ProcessManifestWrites not called during recovery
CompactionService NO N/A Remote workers don't run ProcessManifestWrites
User-defined timestamps YES YES Correctly handled via timestamp_size and persist_user_defined_timestamps
Concurrent SuggestCompactRange YES YES Phase 1 only reads number/level of existing files

Assumption verification:

  • "No change in release builds" — VERIFIED. All version_set.cc changes inside #ifndef NDEBUG. Structs defined unconditionally but only used in NDEBUG-guarded code and tests.
  • "BlobFileMetaData immutable" — VERIFIED. Copy/move deleted, all members set at construction.
  • "Only PMW thread changes wals_" — VERIFIED. Modified at Reset (recovery), install path (PMW), and VersionEditHandler (recovery). No concurrent access.
  • "Base Versions referenced" — VERIFIED. BaseReferencedVersionBuilder calls version_->Ref() at version_builder.cc:2202.
  • "WAL rejection recovery" — VERIFIED. Reset to null, re-fill on next call.

Positive Observations

  • Build-time tag checklist: ManifestRowFieldOfTag and ManifestRowFieldOfNewFileTag switches with no default case force build failures when new tags are added. Excellent guardrail.
  • Two-phase debug check: Phase 1 (no mutex, O(files)) and phase 2 (mutex held, O(edits)) minimizes mutex hold time while verifying all fields.
  • Comprehensive documentation: The 60+ line debug_manifest_rows_ comment in version_set.h and the "In-memory differences" section in manifest_rows.h are thorough.
  • Defensive WAL rejection handling: Robust reset-and-refill on the next call.
  • Test quality: ManifestRowChangesMatchVersions covers file add/move/compaction, blob garbage/removal, atomic groups, WAL operations, CF add/drop, options edits, dummy edits, and verifies check counts via sync points. ManifestRowsRoundTrip sets every field to non-default values.

ℹ️ About this response

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

Limitations:

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

Commands:

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

@meta-codesync meta-codesync Bot changed the title Add internal MANIFEST row model and row changes of each MANIFEST write (#15734) Add internal MANIFEST row model and row changes of each MANIFEST write Nov 24, 2026
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 24, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
@meta-codesync meta-codesync Bot changed the title Add internal MANIFEST row model and row changes of each MANIFEST write Add internal MANIFEST row model and row changes of each MANIFEST write (#15734) Nov 24, 2026
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 24, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 24, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 24, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 24, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 24, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 24, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 24, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 24, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 24, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes, applies them to a debug copy of the rows, and checks the result against the new Versions. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Claude Code Review - OBSOLETE

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

✅ Claude Code Review

Auto-triggered after CI passed — reviewing commit 0943ba7


Summary

Well-structured, carefully designed addition of an internal MANIFEST row model for debug-only verification. The code is debug-only (#ifndef NDEBUG), creates no release-build impact, makes no format or public API changes, and includes thorough tests with tag checklists that force build failures when new tags are added without updating the row model. The locking protocol is correctly designed with a two-phase check that minimizes DB mutex hold time.

High-severity findings (0):

No high-severity findings.

Full review (click to expand)

Findings

🔴 HIGH

None.

🟡 MEDIUM

M1. BaseReferencedVersionBuilder::version() accessor exposes private member — db/version_builder.h:131
  • Issue: The new version() accessor makes the previously private version_ member publicly accessible. While currently only used by the debug-only MakeManifestBatchVersions(), this accessor is available in release builds and could be misused by future callers to bypass the builder's ownership contract (the builder holds a reference to this Version; external callers might not respect that).
  • Root cause: The accessor is needed by debug-only code but is unconditionally public.
  • Suggested fix: Consider either: (a) making the accessor #ifndef NDEBUG-guarded, or (b) adding a comment that this is for debug/test use only, or (c) making MakeManifestBatchVersions a friend. Option (b) is simplest and consistent with existing patterns in the codebase.
M2. Fill step copies all file metadata under DB mutex — db/version_set.cc:6118
  • Issue: GetManifestRows() copies metadata of every live file while holding the DB mutex. For large DBs (100K+ SST files), this could cause a noticeable mutex hold time spike on the first LogAndApply() call and after WAL edit rejection. The PR description acknowledges this but it deserves explicit documentation of the expected cost.
  • Root cause: The fill step runs under the DB mutex by design, but the cost is O(total live files).
  • Suggested fix: This is documented in the PR description and header comments, and only affects debug builds. The cost is bounded (one-time per fill) and subsequent calls use incremental row changes. The existing documentation is adequate; this is a note for awareness rather than a required change.
M3. ManifestRowsToRecords always emits WAL deletion record — db/manifest_rows.cc (ManifestRowsToRecords)
  • Issue: ManifestRowsToRecords() always emits a DeleteWalsBefore(db.min_log_number_to_keep) record, even when min_log_number_to_keep is 0. While DeleteWalsBefore(0) is a no-op during recovery, it adds an unnecessary record. WriteCurrentStateToManifest() does not emit this when it's 0 (it embeds it in the default CF record, only when non-zero). The round-trip test passes because recovery handles it correctly, but it's a minor divergence from the existing MANIFEST writing pattern.
  • Root cause: No guard on min_log_number_to_keep == 0 before emitting the WAL deletion record.
  • Suggested fix: Consider guarding with if (db.min_log_number_to_keep != 0) for consistency, though functional correctness is not affected.

🟢 LOW / NIT

L1. Minor: ManifestRowsToRecords indentation — db/manifest_rows.cc
  • Issue: At the AddBlobFileGarbage call, the indentation of the continuation line uses spaces that may not match .clang-format exactly:
    files_edit.AddBlobFileGarbage(addition.GetBlobFileNumber(),
                                  blob_file.second.garbage_blob_count,
                                  blob_file.second.garbage_blob_bytes);
    The second and third arguments appear over-indented by one space compared to the opening parenthesis alignment.
  • Suggested fix: Run make format-auto.

Cross-Component Analysis

Context Affected? Assessment
Release builds NO All new code behind #ifndef NDEBUG
Secondary/Follower instances NO Don't run ProcessManifestWrites
WritePreparedTxnDB YES (debug builds) Safe: uses same ProcessManifestWrites path
ReadOnly DB NO No MANIFEST writes
Recovery YES (fill step) Safe: fills from installed state under mutex
Concurrent writers Safe Only one PMW thread at a time; debug_manifest_rows_ is single-threaded
DB mutex hold time (phase 2) Minimal O(edits) + O(live WALs) + O(levels for CF add)
DB mutex hold time (fill step) O(total files) One-time cost, debug builds only

Assumption stress-test:

  • Claim: "Only one thread runs ProcessManifestWrites at a time" — Verified: manifest_writers_ queue serializes; only the front writer runs PMW.
  • Claim: "Phase 1 reads of wals_ are safe without mutex" — Verified: only PMW thread changes wals_ (and recovery, which doesn't overlap with PMW).
  • Claim: "FileMetaData immutable fields are safe to read without mutex" — Verified for number and level (phase 1 only reads these for shared files). marked_for_compaction can be changed by other threads, but phase 1 only reads it for newly added files (which are not yet shared).
  • Claim: "BlobFileMetaData objects are immutable" — Verified: BlobFileMetaData has deleted copy/move constructors and no mutable methods.

Positive Observations

  1. Tag checklist pattern: The ManifestRowFieldOfTag() and ManifestRowFieldOfNewFileTag() functions with exhaustive switches (no default case) are an excellent pattern that forces build failures when new tags are added without updating the row model. This is a maintainability best practice.

  2. Two-phase debug check design: Splitting the check into phase 1 (no mutex, O(files)) and phase 2 (mutex held, O(edits)) is well-designed to minimize mutex contention in debug builds.

  3. Comprehensive test coverage: The ManifestRowsRoundTrip test covers all row fields including user-defined timestamps, path IDs, blob files, compaction cursors, dropped CFs, WALs, and OPTIONS file numbers. The ManifestRowChangesMatchVersions test covers all MANIFEST write kinds (file add/move/compact, blob garbage, atomic groups, WAL add/delete/reject, CF add/drop, OPTIONS edits).

  4. Clear documentation: The header file (manifest_rows.h) provides excellent documentation of the design, including the row layout diagram, the rules for BuildManifestRowChanges(), the in-memory differences, and the lifecycle of debug_manifest_rows_.

  5. Thread safety documentation: The debug_manifest_rows_ comment in version_set.h exhaustively lists what phase 1 reads and why each is safe, which is valuable for future maintainers.

  6. WAL rejection handling: The design correctly handles the edge case where a WAL edit is rejected: debug_manifest_rows_ is reset, and the next call re-fills from the installed state. The test covers this case.


ℹ️ About this response

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

Limitations:

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

Commands:

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

@meta-codesync meta-codesync Bot changed the title Add internal MANIFEST row model and row changes of each MANIFEST write (#15734) Add internal MANIFEST row model and row changes of each MANIFEST write Nov 25, 2026
@xingbowang
xingbowang force-pushed the export-D133208529 branch 2 times, most recently from 0e232e2 to d53f540 Compare November 25, 2026 01:22
xingbowang added a commit to xingbowang/rocksdb that referenced this pull request Nov 25, 2026
meta#15734)

Summary:
Pull Request resolved: meta#15734

Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes and applies them to a debug copy of the rows. The check then compares the number and level of every SST in each new Version, and the persisted SST fields of the files whose rows the write adds or updates. The phase table at `debug_manifest_rows_` in `db/version_set.h` lists the column family, blob file, DB and WAL checks. "In-memory differences" in `db/manifest_rows.h` lists the differences that the check allows. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, O(live WALs) and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, O(live WALs) for the WAL rows, and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
@github-actions

github-actions Bot commented Nov 25, 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 d53f540


Summary

Well-designed debug infrastructure for MANIFEST row model validation. The two-phase check (phase 1 without mutex for file-heavy work, phase 2 with mutex for installed state) is a sound approach that minimizes mutex hold time for routine writes while still performing comprehensive validation on every debug MANIFEST write.

High-severity findings (0):

No high-severity findings.

Full review (click to expand)

Findings

🟡 MEDIUM

M1. Fill step holds DB mutex while copying all file metadata — db/version_set.cc:6118-6121 (in diff)
  • Issue: GetManifestRows() iterates every column family and every file, calling MakeFileRow() (which invokes AddExistingFile, creating a VersionEdit and copying a FileMetaData per file) for each. For a DB with 100K SST files, this performs ~100K heap allocations and copies under the DB mutex. This runs on the first ProcessManifestWrites() call (typically DB::Open()) and again after a WAL rejection.
  • Root cause: The fill step must snapshot the full state atomically, and the DB mutex is the natural synchronization point. The PR description documents this cost.
  • Mitigation: The fill step runs only twice in practice (open + after WAL rejection, which is rare). The first call is during DB::Open() before the DB serves traffic, so the mutex contention impact is minimal. The subsequent writes use ApplyManifestRowChanges (incremental) instead. This is acceptable for debug-only code.
  • Suggested fix: None required. The design correctly limits full-copy to rare events. Consider documenting the expected file count threshold where this becomes a concern, so future users of the row model for the external store can plan accordingly.
M2. BaseReferencedVersionBuilder::version() accessor exposes private member — db/version_builder.h:131
  • Issue: The new version() accessor makes the previously private version_ member publicly readable. While BaseReferencedVersionBuilder is an internal class, exposing the raw Version* without clear lifetime documentation could lead to misuse by future callers.
  • Root cause: The debug check in MakeManifestBatchVersions() needs access to the base Version's VersionStorageInfo.
  • Suggested fix: Consider making this a friend or protected accessor, or adding a comment that the returned pointer is only valid while the BaseReferencedVersionBuilder is alive. Alternatively, expose VersionStorageInfo* directly instead of the full Version*, since that's what the caller actually needs.
M3. Memory cost of debug_manifest_rows_ not charged to any budget — db/version_set.h:2252-2338 (in diff)
  • Issue: In debug builds, debug_manifest_rows_ holds a copy of all file metadata for all live SST files. For a large DB with 100K files, each ManifestFileRow contains a FileMetaData copy (~200+ bytes with strings), so this adds ~20-30MB of unbudgeted memory. The PR description mentions "about as much memory as the FileMetaData objects" in the ManifestRows comment, which is accurate.
  • Root cause: Debug-only feature; production builds have zero overhead.
  • Suggested fix: Acceptable for debug builds. The memory estimate in the ManifestRows comment ("estimate, not measured") is appropriate. No action needed unless the external metadata store feature reuses this for release builds, at which point it would need to be charged to a memory budget per CLAUDE.md guidelines.

🟢 LOW / NIT

L1. SameFileRow comparison via encoding is expensive but correct — db/manifest_rows.cc (in diff)
  • Issue: SameFileRow() creates two VersionEdit objects, calls AddExistingFile on each, and encodes both to strings for comparison. This is O(encoding_size) per file. Called only for upserted files during the debug check and in ManifestRowsEqual(), so the total cost is bounded by the number of changed files per write.
  • Root cause: Intentional design choice — comparing via encoding ensures that any new persisted field is automatically included without needing to update a field-by-field comparison. The companion ManifestRowFieldOfNewFileTag test ensures the build fails when a new field tag is added.
  • Suggested fix: None. The encoding-based comparison is a good trade-off for maintainability in debug-only code.
L2. std::map used throughout for file collections — db/manifest_rows.h (in diff)
  • Issue: ManifestCfRows::files and ManifestCfRows::blob_files use std::map<uint64_t, ...> rather than std::unordered_map. For large file sets, std::unordered_map would be faster for lookups.
  • Root cause: The PR comment says "The maps are ordered so that ManifestRowsToRecords() gives the same output for the same rows." Ordered maps provide deterministic output and simpler comparison semantics.
  • Suggested fix: None. Deterministic ordering is a valuable property for a row model that may be used for comparison and serialization. The debug-only context makes the O(log n) vs O(1) difference negligible.
L3. ManifestRowsToRecords always emits DeleteWalsBefore even when min_log_number_to_keep is 0 — db/manifest_rows.cc (in diff)
  • Issue: The function unconditionally writes a DeleteWalsBefore(db.min_log_number_to_keep) record. When the value is 0, this is a no-op but adds an unnecessary record.
  • Root cause: Simplicity — the code doesn't special-case the zero value.
  • Suggested fix: Consider guarding with if (db.min_log_number_to_keep > 0), matching the pattern used for SetMinLogNumberToKeep in the DB edit record at the end of the function. Minor, since recovery handles this correctly either way.
L4. Test uses hardcoded file numbers — db/version_set_test.cc (in diff)
  • Issue: Tests use hardcoded file numbers (10-13, 20-21, 30, 40-42, 77, 95) and call FetchAddFileNumber(100) to avoid collisions. This pattern is brittle if future changes to the test infrastructure use more file numbers before the test runs.
  • Root cause: Follows existing test patterns in version_set_test.cc.
  • Suggested fix: None required — this follows the existing convention and the test correctly reserves a range.

Cross-Component Analysis

Context Does code execute? Assumptions hold? Action needed?
Release builds NO — all under #ifndef NDEBUG N/A None
ReactiveVersionSet (secondary/follower) NO — doesn't call ProcessManifestWrites N/A None
ReadOnly DB NO — no MANIFEST writes N/A None
WritePreparedTxnDB YES — PMW is shared YES — debug check validates metadata, not data visibility None
Recovery Partial — fill step runs on first PMW call post-recovery YES — recovery and PMW don't overlap None
DB::Close() / destructor Safe — debug_manifest_rows_ is owned by VersionSet, destroyed when VS is destroyed YES — no PMW runs during destruction None
Concurrent SuggestCompactRange YES — can set marked_for_compaction on shared FileMetaData YES — phase 1 only reads number+level of existing files, reads all fields only for new (upserted) files that no other thread can see None

Thread safety verification:

  • SetDropped() only called from PMW (version_set.cc:6657) and recovery (version_edit_handler.cc:527). Recovery never overlaps with PMW. ✅
  • wals_ mutations only in PMW (6610, 6612), Reset() (construction), and recovery handlers. No overlap. ✅
  • BlobFileMetaData is non-copyable, non-movable, factory-constructed with all fields set at creation. Truly immutable. ✅
  • CF manipulation (add/drop) is never grouped with other writes (line 6178, 6299-6303). The assertion at line 6188 enforces this. ✅

DB Mutex analysis:

  • Fill step (mutex held): O(total files) but runs only on first call (typically DB::Open) and after rare WAL rejection. Acceptable.
  • Phase 1 (no mutex): O(edits + changed files + blob files + WALs). Bounded by write size. No mutex contention.
  • Phase 2 (mutex held): O(edits + live WALs + levels for CF add). Typically a few lookups. Very cheap.
  • No new blocking I/O, waits, or callbacks under the mutex.

Positive Observations

  1. Excellent documentation: The PR has exceptionally thorough documentation — the overview comment in manifest_rows.h, the BuildManifestRowChanges() rules, the phase table at debug_manifest_rows_, and the "In-memory differences" section. This makes the code highly maintainable.

  2. Future-proof tag checklist: ManifestRowFieldOfTag() and ManifestRowFieldOfNewFileTag() use exhaustive switches with no default case, so the build fails (-Wswitch -Werror) when a new VersionEdit tag or NewFileCustomTag is added without updating the row model. This is an elegant way to prevent silent field omissions.

  3. Sound two-phase design: Splitting the debug check into mutex-free phase 1 (file-heavy) and mutex-held phase 2 (lightweight) demonstrates careful attention to the DB mutex as a hot lock. The cost under the mutex for routine writes is minimal.

  4. Comprehensive test coverage: ManifestRowsRoundTrip tests every row field with non-default values, including edge cases like UDT timestamp stripping, path IDs, blob files with garbage, compaction cursors, and dropped column families. ManifestRowChangesMatchVersions covers all write types including atomic groups, WAL rejection/recovery, CF add/drop, and dummy writes.

  5. Clean separation: The row model is completely self-contained in manifest_rows.{h,cc}. It doesn't modify any existing data structures or code paths in release builds. The only changes to existing files are the debug hooks in ProcessManifestWrites, the version() accessor, and build file updates.

  6. Correct WAL rejection recovery: When BuildManifestRowChanges encounters a WAL error, it resets debug_manifest_rows_ to null, causing the next PMW call to refill from the installed state. This correctly handles the case where the MANIFEST write succeeded but the in-memory WAL state is inconsistent.


ℹ️ 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:
Background
A planned feature stores the DB metadata (the MANIFEST content) as structured rows in an external metadata store, instead of as a log of VersionEdit records in a file. Each row holds the resulting values of one object: the DB, a column family, an SST file, a blob file or a WAL. A reader gets the whole state by reading all rows, with no history. To keep such rows up to date, each MANIFEST write (one batch of VersionEdits in `VersionSet::ProcessManifestWrites()`) must be turned into the rows it changes. This diff adds the in-memory row model, the conversions between rows and the existing VersionSet and VersionEdit code, and the row changes of each MANIFEST write. In debug builds it checks the row changes of every installed MANIFEST write against the Versions that the write installs. Only tests and this debug check use the rows.

The external store is not in this diff. This diff lands the row model and the conversion rules first, so that every debug test and debug crash test checks the rules on each MANIFEST write. When the store is added, it reuses these functions and their checks.

Previous behavior
RocksDB has no row form of the MANIFEST state.

New behavior
No change in release builds. In debug builds, every MANIFEST write that is installed also builds its row changes and applies them to a debug copy of the rows. The check then compares the number and level of every SST in each new Version, and the persisted SST fields of the files whose rows the write adds or updates. The phase table at `debug_manifest_rows_` in `db/version_set.h` lists the column family, blob file, DB and WAL checks. "In-memory differences" in `db/manifest_rows.h` lists the differences that the check allows. A mismatch stops the process with an assert.

Implementation
Key choices:
- The rules that turn one MANIFEST write into row changes are in the `BuildManifestRowChanges()` comment in `db/manifest_rows.h`.
- The debug check runs in two phases. Phase 1 does the work that grows with the number of files, and it runs without the DB mutex, before the new Versions are installed. Phase 2 checks the values that only the installed in-memory state has (the DB row, the WAL rows, the log number, `full_history_ts_low`, the dropped flag), with the DB mutex held. With the DB mutex held, phase 2 costs a few lookups for each edit, a compare of the WAL rows with the live WAL set in place (O(live WALs), with no copy), and O(levels) for an added column family. For a dropped column family, phase 1 frees its file and blob file rows from the debug copy, and phase 2 erases only its small column family row.
- When the WAL set rejects a WAL edit, the MANIFEST write has happened but the write is not installed. The debug rows are then dropped and filled again from the installed state at the next write, so the check keeps comparing with what memory holds.
- Some values change in memory without a MANIFEST write (for example the log number of an empty column family). The rows keep the values from the edits. The "In-memory differences" paragraph at the top of `db/manifest_rows.h` lists these values.

Safety
No format change, no public API change and no behavior change in release builds.
- `VersionSet::GetManifestRows()` requires the caller to hold the DB mutex, and it copies the metadata of every live file while the mutex is held, so the function is meant for tests, debug checks and tools, not for the write path.
- In debug builds, `ProcessManifestWrites()` copies the metadata of every live file into `debug_manifest_rows_` on its first call in a VersionSet and on its first call after a rejected WAL edit. It holds the DB mutex while it makes this copy. The cost of this copy was not measured. The first call is the first `LogAndApply()` of the VersionSet. That call is often the MANIFEST write of `DB::Open()`. It can also be a call that writes no MANIFEST record, such as the dummy edit of `DB::SetOptions()`.
- On each later write, the work that grows with the number of files runs without the DB mutex, and reads only file fields that no other thread changes. With the DB mutex held, the check costs a few lookups for each edit, an in-place compare of the WAL rows (O(live WALs), with no copy), and O(levels) for a column family that the write adds.
- Secondary and follower instances do not write the MANIFEST, so they never run the check.

Known limitations:
- `VersionSet::GetManifestRows()` never produces rows of dropped column families; `ManifestRowsToRecords()` skips such rows when they are given.
- Rows of the files and blob files of a dropped column family stay in the rows after `ApplyManifestRowChanges()`; `ManifestRowsToRecords()` skips them. The comment of `ManifestCfRow::dropped` describes these rows.
- Recovery from the records of `ManifestRowsToRecords()` sets the next file number to the recorded value plus one, as after every reopen.

Changes visible to existing users: none in release builds. Debug builds do more work per MANIFEST write and stop with an assert when the row changes do not match. Debug builds also keep a copy of the metadata of all live files in memory. The copy is made under the DB mutex on the first `LogAndApply()` of the VersionSet, and again after a rejected WAL edit.

How to read this diff
1. `db/manifest_rows.h`: the overview comment at the top ("Background", the VersionEdit content that has no row field, "In-memory differences"), then the row structs from `ManifestDbRow` to `ManifestRows`, with the layout diagram.
2. State to rows: the `VersionSet::GetManifestRows()` declaration in `db/version_set.h`, then in `db/manifest_rows.cc` `MakeManifestCfRow()`, `MakeBlobFileRow()`, `MakeFileRow()`, `SetManifestCfRows()` and `VersionSet::GetManifestRows()`.
3. Rows to records and comparison: `ManifestRowsToRecords()` (its comment gives the record order and the differences from `VersionSet::WriteCurrentStateToManifest()`), read next to `WriteCurrentStateToManifest()` in `db/version_set.cc`; then `SameCfRow()`, `SameFileRow()` and `ManifestRowsEqual()`.
4. Row changes: `ManifestRowChanges` and `ApplyManifestRowChanges()`; then `ManifestBatchVersion` and the `BuildManifestRowChanges()` comment, which holds all rules, and its code. `BaseReferencedVersionBuilder::version()` in `db/version_builder.h` is a one-line accessor for the base Version.
5. Debug check: the `debug_manifest_rows_` comment in `db/version_set.h` (timeline, phase table, threads); the three `#ifndef NDEBUG` hooks in `VersionSet::ProcessManifestWrites()`; then in `db/manifest_rows.cc` `MakeManifestBatchVersions()`, `DebugCheckRowsBeforeInstall()`, `AssertCfRowsMatchVersion()` and `DebugCheckRowsAfterInstall()`.
6. Tests in `db/version_set_test.cc`: `ManifestRowFieldOfTag()` and `ManifestRowFieldOfNewFileTag()` (the checklist for new tags), then `ManifestRowsRoundTrip` and `ManifestRowChangesMatchVersions`.
The build files (`src.mk`, `CMakeLists.txt`, `BUCK`) only add the new source file.

Differential Revision: D133208529
@github-actions

Copy link
Copy Markdown

✅ Claude Code Review

Auto-triggered after CI passed — reviewing commit 76193e8


Summary

Well-designed debug-only infrastructure for verifying MANIFEST row changes against installed Versions. The code is carefully structured with a two-phase check that minimizes DB mutex hold time, thorough documentation of thread safety invariants, and comprehensive tests. No high-severity issues found.

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

Full review (click to expand)

Findings

🟡 MEDIUM

M1. Fill step runs under DB mutex for skip_manifest_write path unnecessarily -- version_set.cc:6115
  • Issue: The fill step (GetManifestRows under DB mutex) runs unconditionally at the top of ProcessManifestWrites, including for skip_manifest_write calls (e.g., MarkNoManifestWriteDummy). For a DB with many files, this copies all file metadata under the mutex even though no debug check will run for that call.
  • Root cause: The fill step is placed before the skip_manifest_write check for simplicity.
  • Impact: Low in practice -- the fill step only runs when debug_manifest_rows_ is null (first call or after WAL rejection), and the rows are reused by the next real write. But for a DB opened with many files, the first ProcessManifestWrites call (which might be a dummy from SetOptions) pays the full copy cost.
  • Suggested fix: Guard with if (!skip_manifest_write) or document that this is acceptable because it happens at most once per session.
M2. BuildManifestRowChanges scans all edits once per batch_versions entry -- manifest_rows.cc (BuildManifestRowChanges, section 2)
  • Issue: In section 2 of BuildManifestRowChanges, for each ManifestBatchVersion, the function iterates through ALL edits to find those matching the column family. For a batch with N edits and M column families with new Versions, this is O(N*M). In a large batch with many column families, this could be non-trivial.
  • Root cause: Simple linear scan rather than pre-grouping edits by column family.
  • Impact: Low -- debug builds only, without the DB mutex, and typical batches have few column families.
  • Suggested fix: Consider pre-grouping edits by CF id, though this may not be worth the complexity for a debug-only path.
M3. ManifestRowsToRecords unconditionally emits a DeleteWalsBefore record -- manifest_rows.cc (ManifestRowsToRecords)
  • Issue: ManifestRowsToRecords always writes a DeleteWalsBefore(db.min_log_number_to_keep) record, even when min_log_number_to_keep is 0. WriteCurrentStateToManifest conditions this on min_log_number_to_keep() > 0. While DeleteWalsBefore(0) is a no-op during recovery, this is an unnecessary record and an inconsistency with the existing code.
  • Root cause: Simplification in the row-to-record conversion.
  • Suggested fix: Guard with if (db.min_log_number_to_keep > 0) to match WriteCurrentStateToManifest.

🟢 LOW / NIT

L1. SameFileRow allocates two VersionEdit objects per comparison -- manifest_rows.cc
  • Issue: SameFileRow creates two VersionEdit objects, calls AddExistingFile on each, encodes both, and compares strings. This auto-adapts to new fields (a strength), but allocates for every file comparison. Only used in debug checks and tests.
L2. Asymmetric equality: ManifestDbRow/ManifestBlobFileRow use defaulted operator== while ManifestCfRow uses SameCfRow -- manifest_rows.h/manifest_rows.cc
  • Issue: Correct (InternalKey needs special comparison for empty/unset keys) but the asymmetry could confuse future contributors. The comment in SameCfRow explains the reason.
L3. MakeManifestCfRow REQUIRES comment could be clearer about mutex-free debug path -- manifest_rows.cc
  • Issue: The REQUIRES line says "Holding the DB mutex is enough" but the debug check calls it without the mutex. The comment does mention this, but a reader scanning just the REQUIRES line might miss the exception.

Cross-Component Analysis

Context Affected? Safe? Reason
WritePreparedTxnDB Yes (debug) Yes Checks MANIFEST rows, not memtable visibility
ReadOnly/Secondary No N/A No MANIFEST writes
User-defined timestamps Yes Yes Tested in ManifestRowsRoundTrip with UDT CF
BlobDB Yes Yes Blob file rows tracked and tested
Concurrent writers Yes Yes Only one PMW thread; documented thread safety
skip_manifest_write Partial Yes Fill step runs; no check runs (M1 above)

Positive Observations

  • Excellent documentation: The debug_manifest_rows_ comment in version_set.h (lifecycle, phases, thread safety, what each phase checks) is exemplary.
  • Two-phase design: O(files) work without mutex, O(edits + WALs) with mutex -- minimizes debug impact on contention.
  • Tag checklist tests: No-default switches in ManifestRowFieldOfTag/ManifestRowFieldOfNewFileTag force updating the row model when new tags are added -- excellent maintenance pattern.
  • Comprehensive round-trip test: Every field set to non-default, with UDT timestamp removal exercised.
  • Zero release-build cost: Everything inside #ifndef NDEBUG.

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

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