Skip to content

Adopt a CAS blob only when its marker reads Clean - #2552

Merged
filimonov merged 4 commits into
antalya-26.6-20261008from
fix/antalya-26.6/cas-360-adopt-only-clean-marker
Oct 14, 2026
Merged

filimonov merged 4 commits into
antalya-26.6-20261008from
fix/antalya-26.6/cas-360-adopt-only-clean-marker

Conversation

@filimonov

Copy link
Copy Markdown
Member

A writer could commit a reference to a CAS blob that GC had just deleted. PartWriteTxn::ensureBlobPresent reads the body with HEAD, then the .meta marker with a separate GET. If GC deleted the body and then the marker between those two reads, the writer took the missing marker for Clean, backfilled it, and adopted a body that no longer existed. Now only a Clean marker read after the HEAD permits adoption; a present body with no marker is republished like an absent one.

Changes

  • Adoption: ensureBlobPresent adopts only on Clean; the putMetaIfAbsent backfill is gone. CASMetaAdoptBackfill is replaced by CASMetaAbsentRepublish (publication attempts started on an absent marker).
  • GC marker delete: Gc::applyRedeleteOutcome passes the deleting round − 1 as the bound, so a Condemned marker that the graduation gate re-stamped at a later round is removed with its body. Before, it outlived the body forever and fsck reported it as meta_without_body.
  • Docs: blob-protocol.md, garbage-collection.md, design-history.md, backend.md, part-lifecycle.md, metrics_and_events.md describe the new rule.

Risks / notes

  • A publication that lands but loses its response is now uploaded once more, with a fresh envelope, instead of adopted. On a 26.6.4 test stand over 16.8 days, absent-marker adoptions were 8 against 2.82 M blob publications.
  • Mixed versions: 26.6.4 writers still backfill and adopt, so the race stays open for them until every writer is upgraded. The wider marker delete affects only re-stamped markers (3 in 17 days on the same stand).
  • Dashboards that read CASMetaAdoptBackfill see 0 after the upgrade; read CASMetaAbsentRepublish.

Testing

  • New, failing on the base: CASPartWriteTxnMarkerRace.AbsentMarkerAfterHeadRepublishes (deletes body and marker between the writer's HEAD and marker GET; the base adopts a deleted body), CASPartWriteTxnMarkerRace.PresentBodyWithoutMarkerRepublishesOnce, CASGcMarker.RedeleteRemovesMarkerRestampedByGate.
  • Tests that pinned adoption on an absent marker now expect one republication, then Clean (CASPartWrite.AmbiguousLandedWriteRepublishesOnceThenClean, CASPartWrite.AmbiguousCopyLandedRepublishesOnceThenClean, CASUploadDetached.*WithoutMetadata*).
  • CAS* gtest: release 2626/2626, ASan 2630/2630.
  • TLA+: CaGcCondemnMarkerGate reproduces the loss when the writer's two reads are separate steps; the fix is green with GC faults, deposed GC attempts and a recurring envelope token.

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Fixes a rare data loss on CAS (content-addressed storage) disks: an insert that reused an existing blob at the moment GC deleted it could commit a reference to the deleted blob, and later reads of that part failed. The writer now uploads the blob again when its freshness marker is missing instead of reusing it.

Documentation entry for user-facing changes

The CAS architecture docs (docs/en/antalya/cas/architecture/) and the CASMetaAbsentRepublish event in docs/en/antalya/metrics_and_events.md are updated in this PR.

CI/CD Options

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • Aarch64 tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (mostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • CAS (content-addressed storage; Antalya only)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • OAuth (5m)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • S3 Export (2h)
  • Swarms (30m)
  • Tiered Storage (2h)

filimonov and others added 4 commits October 12, 2026 18:53
`PartWriteTxn::ensureBlobPresent` reads the body with `HEAD`, then the
marker with a separate `GET`. GC deletes the marker right after the body,
so a writer whose `GET` landed after both deletes found no marker,
backfilled `Clean` and adopted a deleted body.

An absent marker now proves nothing: the body is republished as if absent
and the reconcile creates the marker. `CASMetaAdoptBackfill` is replaced by
`CASMetaAbsentRepublish`. A publication that landed but lost its response
now costs one more upload.

Signed-off-by: Mikhail Filimonov <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
The graduation gate's retry stamps the refusing round, later than
`entry.condemn_round`, so `deleteConfirmedMeta` bounded by the entry's
round left that `Condemned` marker over a deleted body forever. Bound the
delete by the round before the deleting one. Removing a marker never lets
a writer adopt, since adoption needs a `Clean` marker.

Signed-off-by: Mikhail Filimonov <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Fix the `newest_round` argument comment that clang-tidy rejects. Seed a
`Clean` marker in the two remaining `CASProtocol` tests that relied on
adopting a body without one. Correct the user docs, the README and the
comments that still said an absent marker permits adoption or that the
marker delete stops at the entry's round. `CASMetaAbsentRepublish` counts
publication attempts, not uploads.

Signed-off-by: Mikhail Filimonov <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ocol

The redelete diagram still named the old bound; the delete job removes
markers below the deleting round. A failed delete job can still leave a
`Condemned` marker behind, so the text no longer says none outlives its body.

Signed-off-by: Mikhail Filimonov <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-actions

Copy link
Copy Markdown

Workflow [PR], commit [e7535fd]

@filimonov
filimonov merged commit fef96d5 into antalya-26.6-20261008 Oct 14, 2026
360 of 371 checks passed
@k-morozov k-morozov added the verified Approved for release label Oct 15, 2026
@filimonov

Copy link
Copy Markdown
Member Author

Ported to antalya-26.8 in #2805 (commit ba448a8).

One adaptation: on 26.8 ProfileEvents::Counters::operator[] returns the value, so gtest_cas_part_write.cpp reads the counters without .load() (conflict in the pick plus 78de57b).

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.

3 participants