Add DBOptions::partition_wal_usage for per-record WAL ordering numbers (wal_index) - #15151
Closed
JustinGaoF wants to merge 1 commit into
Closed
Add DBOptions::partition_wal_usage for per-record WAL ordering numbers (wal_index)#15151JustinGaoF wants to merge 1 commit into
JustinGaoF wants to merge 1 commit into
Conversation
…s (wal_index) Summary: Adds a new `DBOptions::partition_wal_usage` (`PartitionWALUsage` enum) that controls whether each logical WAL record carries a monotonically increasing ordering number (wal_index / LSN) persisted on disk. - `kNone` (default) keeps the WAL bit-for-bit compatible with the previous format for downgrade safety. - `kPartitionByWALIndexHash` enables the feature: `log::Writer` prepends a fixed64 wal_index to every logical record (starting at 1, incremented per `AddRecord`), and emits a leading marker record (`kWALIndexMarkerType` / `kRecyclableWALIndexMarkerType`, magic `WAL_LSN_V1`) that identifies the file as carrying wal_index. The marker type is `< 128` without the safe-ignore bit, so older binaries report corruption instead of misreading the file. On the read side, `log::Reader` detects the marker, strips the wal_index from each logical record so upper layers observe the original payload, recomputes the per-record checksum over the stripped payload, and reports a corruption (with a sticky gap flag) when the observed wal_index is not the expected successor. The index survives block fragmentation, recyclable headers, and WAL compression. The marker and file-level meta records do not consume a wal_index. The option is parseable from an options string (both `partition_wal_usage` and `Partition_WAL_Usage`, values `kNone`/`None` and `kPartitionByWALIndexHash`/`partition_by_wal_index_hash`), and is wired into `db_bench`, `db_stress`, and `db_crashtest.py`. Differential Revision: D117410129
|
@JustinGaoF has exported this pull request. If you are a Meta employee, you can view the originating Diff in D117410129. |
|
@JustinGaoF has imported this pull request. If you are a Meta employee, you can view this in D117410129. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Adds a new
DBOptions::partition_wal_usage(PartitionWALUsageenum) thatcontrols whether each logical WAL record carries a monotonically increasing
ordering number (wal_index / LSN) persisted on disk.
kNone(default) keeps the WAL bit-for-bit compatible with the previousformat for downgrade safety.
kPartitionByWALIndexHashenables the feature:log::Writerprepends afixed64 wal_index to every logical record (starting at 1, incremented per
AddRecord), and emits a leading marker record (kWALIndexMarkerType/kRecyclableWALIndexMarkerType, magicWAL_LSN_V1) that identifies the fileas carrying wal_index. The marker type is
< 128without the safe-ignorebit, so older binaries report corruption instead of misreading the file.
On the read side,
log::Readerdetects the marker, strips the wal_index fromeach logical record so upper layers observe the original payload, recomputes the
per-record checksum over the stripped payload, and reports a corruption (with a
sticky gap flag) when the observed wal_index is not the expected successor. The
index survives block fragmentation, recyclable headers, and WAL compression.
The marker and file-level meta records do not consume a wal_index.
The option is parseable from an options string (both
partition_wal_usageandPartition_WAL_Usage, valueskNone/NoneandkPartitionByWALIndexHash/partition_by_wal_index_hash), and is wired intodb_bench,db_stress, anddb_crashtest.py.Differential Revision: D117410129