Skip to content

CAS GC: graduation read-ahead can accept a stale condemn marker #2486

Closed as not planned

Description

@DimensionWieldr

A live part can keep a reference to blob bytes that GC has already deleted. Reads of that part then fail because the object is gone.

An insert adopts a blob whose marker says Clean, and commits a part that names that object. GC has already decided to delete the same object, from an earlier look at the marker, and the delete goes through. The part stays. The bytes do not. A later SELECT, merge, or mutation that opens the part fails when the GET of the blob returns missing. Retrying the query does not bring the bytes back.

The body is one object in shared storage, keyed by content hash. Every part that deduplicated onto that hash loses it, on every replica.

This is a narrow window, which is why it shows up as a rare lost part rather than a failed GC round. If the adopting insert lands before the delete round's intake cut, that round sees the new edge and keeps the blob. If nobody adopts before the delete, the body was unreferenced and removing it is correct. The lost part is the insert that adopts after that cut and before the delete.

Related: #2463
Related: CAS-334 (publisher never turns Condemned into Clean)

Why the gate misses Clean

#2463 made graduation read X.meta and accept it only when it is Condemned at the entry's round or newer. Concurrency 1 does that read at the decision, sees Clean, refuses, and re-stamps Condemned. A writer that then arrives republishes instead of adopting, and the exact-token delete does not match the new body.

With the default cas_gc_io_concurrency of 16, the read is issued early. GraduationReadHints::admit / offer and PriorEdgeCursor::scanAhead call hintRead up to kGraduationLookaheadRows (16384) rows before the gate. confirm_condemned_marker uses GcReadAhead::takeRead, which returns that earlier GET. The marker is not write-once.

Gc::fold in src/Disks/DiskObjectStorage/MetadataStorages/ContentAddressed/Gc/CasGc.cpp:

if (const auto lm = decodeLoadedMeta(reads.takeRead(key));
    lm && lm->meta.state == MetaState::Condemned && lm->meta.condemn_round >= entry.condemn_round)
    return true;

A publisher reconcileMetaClean in that gap — the abort-after-Clean interleaving from #2463 — leaves Clean on the object while the gate still sees Condemned and publishes delete_pending. The accept path does not re-stamp, so the marker stays Clean.

The delete round does not look again. A delete_pending entry with in-degree 0 goes to performRedeleteIo, which HEADs the body and deletes that token. The insert described above precommits after this round's cut, reads the leftover Clean, and adopts the same token.

The touched-row budget rule keeps the graduated set identical only when the marker does not change between the hint and the gate. GraduationReadAheadDecidesOnTheFetchedValue rewrites the marker to Clean after the GET and expects graduated == 1, so the stale accept is currently the tested behavior.

Fix direction

Decide only on a marker read issued at the gate. A hint must not be the value confirm_condemned_marker accepts.

At concurrency 16, write Clean after the hinted GET completes and before the cursor reaches the entry. Expect graduated == 0, matching concurrency 1.

Activity

  1. filimonov commented on Oct 7, 2026

    @filimonov
    Member

    Not caused by #2463, and not a new loss. The comparison in the issue is concurrency 1 against concurrency 16 inside the PR; the comparison that matters is base against PR.

    Base. Graduation did not read the marker at all: it published delete_pending from the in-process confirmation. A Clean written by a publisher at any point after condemnation was never seen. That is S2, the loss #2463 fixes.

    PR. Graduation reads the marker after the round's cut and refuses on anything but Condemned at the entry's round or newer. The read goes through the GC read-ahead: a GET is issued when a slot is free (graduation_reserved.size() < reads.window(), window = cas_gc_io_concurrency + 1), and the gate takes it when the cursor reaches the row. The 16384 of kGraduationLookaheadRows is the scan distance for candidates, not the age of a GET. The value at the gate is as old as the walk over about 16 graduating entries, inside the same fold.

    What the gap can hold. A Clean that lands between the hint and the gate is accepted; a Clean that lands right after the gate is accepted at concurrency 1 as well, and the entry then sits under Clean until the delete round either way. So the question is who writes Clean after the cut. The ordinary publisher does not: its abort waits for its reconcile, so an abort-after-Clean puts the Clean before the cut, where the hint and the gate both see it (the issue's reading of that interleaving is off by this step). The two sources that remain are the ones the spec lists as not closed by this PR, section 10 of docs/superpowers/specs/2026-09-30-cas-gc-meta-delete-names-its-condemnation-design.md: a namespace removal while the publisher's reconcile is in flight (10.1), and a PUT Clean If-Match that lands after more than one GC interval (10.2). Both need a request outstanding past its timeout and the lease period; both lose on base too; both are closed by CAS-334 (a publisher never turns Condemned into Clean), after which the age of the gate's read stops mattering at all.

    Model. The TLA+ gate read the marker atomically, so on this point the code did not refine it. 363b419 adds MarkerPrefetch: GObserveMeta copies the marker after the cut, GateOK tests the copy. 28 rows, all expectations met. Every green row stays green with the flag (pm_g1_mpf_noregistry, rv_g1_mpf_noregistry, pm_g1_mpf_late_resolved); the one violation it reaches is pm_g1_mpf_extdrop, the 10.1 residual, which pm_g1_extdrop_noregistry reaches without the flag.

    Test. GraduationReadAheadDecidesOnTheFetchedValue pins that the decision is made on the value the gate holds and nothing else is re-read at the gate; at concurrency 1 and 8 the same Clean after the GET gives the same result. It is the intended behaviour, and the comment there and at confirm_condemned_marker will say how old the value may be and why that is covered.

    Keeping the read-ahead. Dropping the Caused by; related: #2463, CAS-334.

  2. DimensionWieldr commented on Oct 7, 2026

    @DimensionWieldr
    CollaboratorAuthor

    Closing this as a non-issue.

    The lost part described here is not a new failure from #2463. The ordinary publisher writes its precommit edge, then reconciles the marker to Clean, and only after that can the edge disappear (ContentAddressedTransaction::publishStaging). A GC cut that already sees the blob unreferenced therefore already has Clean stored, and both the hinted GET and a read at the gate see it and refuse. That is the schedule #2463 closes. On the base build the gate never read the marker, so that Clean was missed.

    A Clean that arrives after the cut still loses, and it already lost on the base build. The two sources are a namespace drop that removes the edge while reconcile is in flight, and a PUT Clean If-Match that completes only after more than one GC interval. Both are the residuals left to CAS-334. Read-ahead does not add a schedule that the base build kept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CASantalyaantalya-26.6bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions