Skip to content

[Muse][GC] GC23: Recovery and consumer carry-over after GC19 and GC22 - #19

Closed
JustinGaoF wants to merge 1 commit into
pwal/gc23-basefrom
pwal/gc23-muse
Closed

JustinGaoF wants to merge 1 commit into
pwal/gc23-basefrom
pwal/gc23-muse

Conversation

@JustinGaoF

Copy link
Copy Markdown
Owner

[Muse][GC] GC23: Recovery and consumer carry-over after GC19 and GC22

[GC] GC23: Recovery and consumer carry-over after GC19 and GC22

Reviewer question: Can any recovery path now replay a superseded record,
skip a superseded-only hole, or accept a damaged unattested head, and are
GC22's snapshot and secondary fixes fully pinned?

Answer, one question at a time. Property, how, evidence, neuter.

Q1 -- supersession after data fails closed (option (a)).
Property: no path replays a superseded record. The writer guarantees
supersessions land only on the fresh log before its first data record;
recovery fails closed on any violation, in every mode.
How: asserts in WriteWALIndexSupersessions (fresh log,
first_wal_index_recorded()==0); a sticky SawMisplacedSupersession flag in
log::Reader set where a misplaced declaration is already reported;
fail-closed guards on it in ProcessLogFile (sequential) and
WALIndexMerger::PullMembers (merge, via a Member virtual).
Evidence: LogMergeTest.GC23MisplacedSupersessionFailsMerge and
DBWALIndexTest.GC23MisplacedSupersessionFailsSequentialReplay pass at
commit, fail at base. The higher-numbered case of
GC19ReportedTailGapStopsPITEitherPartition is labeled: it passes under the
report-ignoring neuter and discriminates the complementary neuter.
Neuter: head-only detection with no guard (the base). Complementary
neuter (status-driven arm dropped in map_tail_gap): the GC19 test fails
at "torn WAL numbered higher".
Ported: none (new tests).

Q2 -- deleted current indexed WAL after SyncWAL: no production change.
Property: a current WAL is legitimately untracked (the MANIFEST tracks
inactive WALs only; probed WalSet after SyncWAL shows the current WAL
untracked), so its loss reads as a torn tail, no weaker than the base.
How: rule stated and pinned by test; no code change.
Evidence: DBWalPartitionCoverageTest.GC23UntrackedCurrentWalLossReadsTrailing
passes identically at base and commit.
Neuter: none applies (no fix); argued, not tested, beyond the probe.

Q3 -- HeadBounded floor term narrowed.
Property: the floor term holds only while some member holds indexed
data. A damaged head still fails closed with "head damaged and
unattested" wherever the floor does not prove start-of-history; the
brand-new N>=2 DB with a torn first record still opens.
How: HeadBounded's floor term gains SomeMemberHoldsIndexedData(); both
gates reading it (post-drive head check, lower-bound damaged-head gate)
are correct under it: with no indexed data anywhere the drive ends clean
without examining any index.
Evidence: ported GC19H6FloorSetAbsoluteAndSkipOutcomes and
GC19H6FloorUnsetHeadDamageStillFails (Muse, GC19) pass at commit and base;
new GC23FloorSetNoDataHeadDamageStillFails (lower-bound gate, floor set,
no data) passes at commit, fails at base.
Neuter: the GC19 floor term (base) fails the new test; removing the
floor term entirely fails FU14H6TornFirstRecordInBrandNewNTwoDb and the
ported FloorSet test, while GC19TornFirstRecordAfterFlushStaysDamaged
still passes.

Q4 -- Q2 void exception at N>1, DB-level (N in {2,8}).
Property: a pre-cut void clears the pending superseded-only index and
the open ends clean; a post-cut void (declarer or later) does not:
point-in-time stops at the pending index.
How: the premise is asserted where supersessions are written (declarer
is the lowest-numbered WAL the open creates:
new_log->get_log_number()==cur_wal_number_); the merge keeps the rule;
the frontier path cuts a clean member holding records at/above the seed
and seeds past voids read above the frontier.
Evidence: DBWalPartitionCoverageTest.GC23VoidExceptionPreAndPostCut
passes at commit; the post-cut arm fails at base.
Neuter: clear the pending index on any void: the post-cut arm fails
("post-cut void leaves the pending index").

Q5 -- Muse GC19 merge tests ported; every GC19 test discriminates.
Property: superseded-only hole inside a live stream stops; trailing
superseded hole without live above skips; interleaved set asserts after
each kNone open.
Evidence: LogMergeTest.SupersededOnlyHoleInsideLiveStreamStops and
TrailingSupersededHoleWithoutLiveAboveSkips (Muse, GC19) pass at commit;
DBWALIndexTest.InterleavedMixedSetWithSupersessionsFailsClosed ports
Muse's scenario, reworked to assert after each kNone open (both OK with
keys 6/7 NOT_FOUND on this base).
Neuter: unconditional skip of superseded-only holes fails
SupersededOnlyHole (4/4) while Trailing still passes (pins the skip
side); ignoring head declarations (superseding=false) fails the
interleaved port and GC19's InterleavedSupersedingSetFailsClosed and
SupersedingSetOpenedWithoutIndexing.

Q6 -- secondary non-partitioned and retry pinned (test-only).
Evidence: ported DBSecondaryTest.CatchUpEmptyUnindexedWalAppliesNothing
and CatchUpRefusesIndexedRoundWithEmptyHead (Muse, GC22); pass at commit
and base.
Neuter: pre-scan refusing any empty head regardless of indexing fails
the first test (aborts in teardown: nothing applied, then progress
expected).

Q7 -- reservation hidden from user-visible snapshot surfaces.
Property: the pre-publish reservation pins versions for compaction and
flush but is excluded from user-visible counts/listings until the
callback completes. GC22's guarantee is unchanged.
How: is_write_reservation_ on SnapshotImpl, set at reservation;
count_visible()/oldest_visible() skip it; num-snapshots,
oldest-snapshot-time/-sequence read the filtered views; documented at
the property declarations. No other user-visible snapshot listing API
exists (full-list readers are compaction/flush internals).
Evidence: TransactionPartitionedWalTest.GC23SnapshotReservationHiddenFromProperties
(holds T1 at RunCompletionGate, reads the three properties) passes at
commit, fails at base (1 vs 0).
Neuter: the opposite behaviour (the base).

Q8 -- N=1-indexed transient refusal decided per D-GC23a option (i).
Property: the secondary's fail-closed refusal of an indexed round with
an empty head is documented in the wal_partitions option doc; the retry
after FlushWAL is pinned by CatchUpRefusesIndexedRoundWithEmptyHead.
Neuter: option (ii) behaviour; argued, not tested (under (ii) the
refusal assertion would fail).

Q9 -- compaction guarantee without SyncPoint (test-only).
Property: concurrent cross-partition commits with snapshot creation,
then flush and compaction, keep every timestamped snapshot reading its
value.
Evidence: TransactionPartitionedWalTest.GC23TimestampedSnapshotsSurviveCompactionStress
(4 committers x 50 snapshots, flush + full compaction per cycle, ~12 s)
passes at commit. The opt harness does not build (pre-existing:
transaction_test.cc:9967 uses debug-only TEST_GetBGError), so it ran in
debug; the test itself uses no SyncPoint and is opt-compatible.
Neuter: precise drop-the-reservation (shared_ptr emptied, gate wrap and
callbacks intact): the stress passes 3/3 (the publish-to-callback race
window is too narrow to hit without a hold), while the SAME neuter fails
GC22TimestampedSnapshotReservedBeforePublish deterministically (value
reads ""). The stress test is a release-build guard; deterministic
discrimination comes from GC22's SyncPoint test.

Fold-back split (hunk -> origin at base -> absorbing diff):

  • db/log_reader.h (flag + accessor), db/log_reader.cc (flag set):
    adjacent D120408456/D120649665/D120415420; new Q1 code ->
    D121636079/D123928339.
  • db/db_impl/db_impl_open.cc writer asserts (Q1+Q4 premise): new code ->
    D120415420.
  • db/db_impl/db_impl_open.cc frontier cut + seed-past-voids (Q4): new
    code in D120649665 region -> D120649665.
  • db/db_impl/db_impl_open.cc sequential misplaced guard (Q1): new code ->
    D121636079/D123928339.
  • db/log_merge.h Member virtual + override, db/log_merge.cc PullMembers
    guard (Q1): new code in D120624825 region -> D121636079/D123928339.
  • db/log_merge.h HeadBounded narrow + SomeMemberHoldsIndexedData (Q3):
    modifies GC19's hunk (GC19 -> D120624825) -> D120624825.
  • db/db_impl/db_impl_write.cc reservation flag (Q7): modifies GC22's
    hunk (GC22 -> D123551605) -> D123551605.
  • db/snapshot_impl.h, db/internal_stats.cc, include/rocksdb/db.h (Q7):
    snapshot property code (+ long-standing snapshot list) -> D123551605
    and the snapshot property code.
  • include/rocksdb/options.h wal_partitions doc (Q8): extends GC18's doc
    hunk -> D127093323.
  • Tests (new code): db/log_merge_test.cc -> D120649665;
    db/db_wal_test.cc -> D120415420; db/db_write_test.cc (Q2/Q3/Q4) ->
    D120649665/D120624825; db/db_secondary_test.cc -> D127093323;
    utilities/transactions/transaction_test.cc Q7 -> D123551605, Q9 ->
    D127275775. One comment-only label on GC19's Q1 test (Q5-sanctioned)
    -> D127093323.

Assumptions:

  • D-GC23a was blank: implemented Recommended (i), fail closed +
    documented.
  • Q1: option (a) (writer guarantee + recovery guard). Q3: narrowed the
    floor term. Q4: asserted the premise, kept the rule. Q7: excluded the
    reservation. Q2: no production change (rule pinned).
  • Repro tests unmodified except the Q5-sanctioned label comment.
  • N=1 kNone unchanged (byte-identical); no new on-disk record type.

Not done: none. All of Q1-Q9 are implemented, tested and verified.

Test plan:

  • Full debug suites (gtest-parallel -w 40, 6945 tests): db_write_test,
    db_wal_test, log_merge_test, log_test, db_secondary_test,
    transaction_test, db_wal_oracle_test, db_basic_test -- all PASS.
  • 100x repeats: Q1 merge+seq, Q2, Q3 (3), Q4, Q5 (3 incl. interleaved),
    Q6 (2), Q7 (100/100 OK) -- all PASS.
  • GC15 oracle: 1000 cycles, seed 20261028 -- PASS (N=2 in 507, N=8 in
    493, 141 cross-partition holes, 526 power-loss).
  • TSan (clang) on every new/changed test across the five touched
    suites -- PASS, no races.
  • N=1 byte identity (release db_bench fillseq, seed 20260928):
    *.log SHA-256 identical base-vs-commit for usage none and
    partition_by_column_family.
  • make check-format (clang-format 21.1.2) and check-sources -- clean.
  • Neuters, each verified by a failing run: Q1 base/complementary, Q3
    base/floor-removal, Q4 any-void, Q5 skip/routing, Q6 refuse-any,
    Q7 base, Q9 reservation-drop (via GC22's test). Q2/Q8: argued, not
    tested, as stated above.

[GC] GC23: Recovery and consumer carry-over after GC19 and GC22

Reviewer question: Can any recovery path now replay a superseded record,
skip a superseded-only hole, or accept a damaged unattested head, and are
GC22's snapshot and secondary fixes fully pinned?

Answer, one question at a time. Property, how, evidence, neuter.

Q1 -- supersession after data fails closed (option (a)).
Property: no path replays a superseded record. The writer guarantees
supersessions land only on the fresh log before its first data record;
recovery fails closed on any violation, in every mode.
How: asserts in WriteWALIndexSupersessions (fresh log,
first_wal_index_recorded()==0); a sticky SawMisplacedSupersession flag in
log::Reader set where a misplaced declaration is already reported;
fail-closed guards on it in ProcessLogFile (sequential) and
WALIndexMerger::PullMembers (merge, via a Member virtual).
Evidence: LogMergeTest.GC23MisplacedSupersessionFailsMerge and
DBWALIndexTest.GC23MisplacedSupersessionFailsSequentialReplay pass at
commit, fail at base. The higher-numbered case of
GC19ReportedTailGapStopsPITEitherPartition is labeled: it passes under the
report-ignoring neuter and discriminates the complementary neuter.
Neuter: head-only detection with no guard (the base). Complementary
neuter (status-driven arm dropped in map_tail_gap): the GC19 test fails
at "torn WAL numbered higher".
Ported: none (new tests).

Q2 -- deleted current indexed WAL after SyncWAL: no production change.
Property: a current WAL is legitimately untracked (the MANIFEST tracks
inactive WALs only; probed WalSet after SyncWAL shows the current WAL
untracked), so its loss reads as a torn tail, no weaker than the base.
How: rule stated and pinned by test; no code change.
Evidence: DBWalPartitionCoverageTest.GC23UntrackedCurrentWalLossReadsTrailing
passes identically at base and commit.
Neuter: none applies (no fix); argued, not tested, beyond the probe.

Q3 -- HeadBounded floor term narrowed.
Property: the floor term holds only while some member holds indexed
data. A damaged head still fails closed with "head damaged and
unattested" wherever the floor does not prove start-of-history; the
brand-new N>=2 DB with a torn first record still opens.
How: HeadBounded's floor term gains SomeMemberHoldsIndexedData(); both
gates reading it (post-drive head check, lower-bound damaged-head gate)
are correct under it: with no indexed data anywhere the drive ends clean
without examining any index.
Evidence: ported GC19H6FloorSetAbsoluteAndSkipOutcomes and
GC19H6FloorUnsetHeadDamageStillFails (Muse, GC19) pass at commit and base;
new GC23FloorSetNoDataHeadDamageStillFails (lower-bound gate, floor set,
no data) passes at commit, fails at base.
Neuter: the GC19 floor term (base) fails the new test; removing the
floor term entirely fails FU14H6TornFirstRecordInBrandNewNTwoDb and the
ported FloorSet test, while GC19TornFirstRecordAfterFlushStaysDamaged
still passes.

Q4 -- Q2 void exception at N>1, DB-level (N in {2,8}).
Property: a pre-cut void clears the pending superseded-only index and
the open ends clean; a post-cut void (declarer or later) does not:
point-in-time stops at the pending index.
How: the premise is asserted where supersessions are written (declarer
is the lowest-numbered WAL the open creates:
new_log->get_log_number()==cur_wal_number_); the merge keeps the rule;
the frontier path cuts a clean member holding records at/above the seed
and seeds past voids read above the frontier.
Evidence: DBWalPartitionCoverageTest.GC23VoidExceptionPreAndPostCut
passes at commit; the post-cut arm fails at base.
Neuter: clear the pending index on any void: the post-cut arm fails
("post-cut void leaves the pending index").

Q5 -- Muse GC19 merge tests ported; every GC19 test discriminates.
Property: superseded-only hole inside a live stream stops; trailing
superseded hole without live above skips; interleaved set asserts after
each kNone open.
Evidence: LogMergeTest.SupersededOnlyHoleInsideLiveStreamStops and
TrailingSupersededHoleWithoutLiveAboveSkips (Muse, GC19) pass at commit;
DBWALIndexTest.InterleavedMixedSetWithSupersessionsFailsClosed ports
Muse's scenario, reworked to assert after each kNone open (both OK with
keys 6/7 NOT_FOUND on this base).
Neuter: unconditional skip of superseded-only holes fails
SupersededOnlyHole (4/4) while Trailing still passes (pins the skip
side); ignoring head declarations (superseding=false) fails the
interleaved port and GC19's InterleavedSupersedingSetFailsClosed and
SupersedingSetOpenedWithoutIndexing.

Q6 -- secondary non-partitioned and retry pinned (test-only).
Evidence: ported DBSecondaryTest.CatchUpEmptyUnindexedWalAppliesNothing
and CatchUpRefusesIndexedRoundWithEmptyHead (Muse, GC22); pass at commit
and base.
Neuter: pre-scan refusing any empty head regardless of indexing fails
the first test (aborts in teardown: nothing applied, then progress
expected).

Q7 -- reservation hidden from user-visible snapshot surfaces.
Property: the pre-publish reservation pins versions for compaction and
flush but is excluded from user-visible counts/listings until the
callback completes. GC22's guarantee is unchanged.
How: is_write_reservation_ on SnapshotImpl, set at reservation;
count_visible()/oldest_visible() skip it; num-snapshots,
oldest-snapshot-time/-sequence read the filtered views; documented at
the property declarations. No other user-visible snapshot listing API
exists (full-list readers are compaction/flush internals).
Evidence: TransactionPartitionedWalTest.GC23SnapshotReservationHiddenFromProperties
(holds T1 at RunCompletionGate, reads the three properties) passes at
commit, fails at base (1 vs 0).
Neuter: the opposite behaviour (the base).

Q8 -- N=1-indexed transient refusal decided per D-GC23a option (i).
Property: the secondary's fail-closed refusal of an indexed round with
an empty head is documented in the wal_partitions option doc; the retry
after FlushWAL is pinned by CatchUpRefusesIndexedRoundWithEmptyHead.
Neuter: option (ii) behaviour; argued, not tested (under (ii) the
refusal assertion would fail).

Q9 -- compaction guarantee without SyncPoint (test-only).
Property: concurrent cross-partition commits with snapshot creation,
then flush and compaction, keep every timestamped snapshot reading its
value.
Evidence: TransactionPartitionedWalTest.GC23TimestampedSnapshotsSurviveCompactionStress
(4 committers x 50 snapshots, flush + full compaction per cycle, ~12 s)
passes at commit. The opt harness does not build (pre-existing:
transaction_test.cc:9967 uses debug-only TEST_GetBGError), so it ran in
debug; the test itself uses no SyncPoint and is opt-compatible.
Neuter: precise drop-the-reservation (shared_ptr emptied, gate wrap and
callbacks intact): the stress passes 3/3 (the publish-to-callback race
window is too narrow to hit without a hold), while the SAME neuter fails
GC22TimestampedSnapshotReservedBeforePublish deterministically (value
reads ""). The stress test is a release-build guard; deterministic
discrimination comes from GC22's SyncPoint test.

Fold-back split (hunk -> origin at base -> absorbing diff):
- db/log_reader.h (flag + accessor), db/log_reader.cc (flag set):
  adjacent D120408456/D120649665/D120415420; new Q1 code ->
  D121636079/D123928339.
- db/db_impl/db_impl_open.cc writer asserts (Q1+Q4 premise): new code ->
  D120415420.
- db/db_impl/db_impl_open.cc frontier cut + seed-past-voids (Q4): new
  code in D120649665 region -> D120649665.
- db/db_impl/db_impl_open.cc sequential misplaced guard (Q1): new code ->
  D121636079/D123928339.
- db/log_merge.h Member virtual + override, db/log_merge.cc PullMembers
  guard (Q1): new code in D120624825 region -> D121636079/D123928339.
- db/log_merge.h HeadBounded narrow + SomeMemberHoldsIndexedData (Q3):
  modifies GC19's hunk (GC19 -> D120624825) -> D120624825.
- db/db_impl/db_impl_write.cc reservation flag (Q7): modifies GC22's
  hunk (GC22 -> D123551605) -> D123551605.
- db/snapshot_impl.h, db/internal_stats.cc, include/rocksdb/db.h (Q7):
  snapshot property code (+ long-standing snapshot list) -> D123551605
  and the snapshot property code.
- include/rocksdb/options.h wal_partitions doc (Q8): extends GC18's doc
  hunk -> D127093323.
- Tests (new code): db/log_merge_test.cc -> D120649665;
  db/db_wal_test.cc -> D120415420; db/db_write_test.cc (Q2/Q3/Q4) ->
  D120649665/D120624825; db/db_secondary_test.cc -> D127093323;
  utilities/transactions/transaction_test.cc Q7 -> D123551605, Q9 ->
  D127275775. One comment-only label on GC19's Q1 test (Q5-sanctioned)
  -> D127093323.

Assumptions:
- D-GC23a was blank: implemented Recommended (i), fail closed +
  documented.
- Q1: option (a) (writer guarantee + recovery guard). Q3: narrowed the
  floor term. Q4: asserted the premise, kept the rule. Q7: excluded the
  reservation. Q2: no production change (rule pinned).
- Repro tests unmodified except the Q5-sanctioned label comment.
- N=1 kNone unchanged (byte-identical); no new on-disk record type.

Not done: none. All of Q1-Q9 are implemented, tested and verified.

Test plan:
- Full debug suites (gtest-parallel -w 40, 6945 tests): db_write_test,
  db_wal_test, log_merge_test, log_test, db_secondary_test,
  transaction_test, db_wal_oracle_test, db_basic_test -- all PASS.
- 100x repeats: Q1 merge+seq, Q2, Q3 (3), Q4, Q5 (3 incl. interleaved),
  Q6 (2), Q7 (100/100 OK) -- all PASS.
- GC15 oracle: 1000 cycles, seed 20261028 -- PASS (N=2 in 507, N=8 in
  493, 141 cross-partition holes, 526 power-loss).
- TSan (clang) on every new/changed test across the five touched
  suites -- PASS, no races.
- N=1 byte identity (release db_bench fillseq, seed 20260928):
  *.log SHA-256 identical base-vs-commit for usage none and
  partition_by_column_family.
- make check-format (clang-format 21.1.2) and check-sources -- clean.
- Neuters, each verified by a failing run: Q1 base/complementary, Q3
  base/floor-removal, Q4 any-void, Q5 skip/routing, Q6 refuse-any,
  Q7 base, Q9 reservation-drop (via GC22's test). Q2/Q8: argued, not
  tested, as stated above.
@JustinGaoF

Copy link
Copy Markdown
Owner Author

GC23 A/B round: the other candidate (#18) was accepted. Closing this one; the commit is kept as pwal/ab/gc23-muse-PR19.

@JustinGaoF JustinGaoF closed this Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant