Files
seaweedfs/seaweed-block/core/host/volume
cccad8d5ce seaweed-block: a stale metadata change cannot land on a re-created intent page (filer chunk condition, page re-read as fallback) (#13457)
* seaweed-block: red: a snapshot delete is published over a page whose data was freed

Two overlapping runs of one snapshot delete write their intent pages under
the same tag. If the first run's stalled page update lands between the
second run's read of a page and its adoption (after a cleaning pass
deleted and the second run re-staged the page), the second run adopts and
publishes an intent whose page data was freed: later snapshot deletes on
the volume are refused and its cleaning stops.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-block: a snapshot delete re-reads each intent page after adopting it

Publication reads every intent page, adopts it under this run's tag, then
publishes. A stalled update from another run of the same delete can land
between that read and the adoption and put a deleted page's data reference
on the entry. Reading the page again after the adoption, before the
transition publishes, refuses that case: once this run's tag is on the
entry, no such update passes. No persisted change; a run that hits it
stays refused, and a new request id writes new pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-block: ledger row for the intent page re-read

INV-SNAPSHOT-DELETE-ADOPT-002 names the re-read after adoption, its test
and the model row it projects (PublishedReadable; the refused run is the
residue a new request id clears).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-block: the intent page re-read: typed refusal, twins and a store witness

Review: the re-read test now separates the guard from weaker ones. A page
that reads but holds other bytes, and a change to only the later of two
pages, are refused as well as a freed page; the refusal is a precondition
that writes nothing to HEAD, keeps the snapshot, and comes after the
adoption; the same schedule with intact bytes publishes. The test is a
consequence-level projection; a store-level witness shows the tag-only
metadata update writing a deleted object's chunk over a re-created one,
which the re-read does not depend on refusing. The ledger row names the
witness and marks the model as checked outside the repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-block: the intent page re-read keeps its error's cause

The refusal wrapped the re-read's error with %v, so a caller deadline
that ended the re-read reached the CLI as a precondition ("page changed
during adoption", no_progress) instead of deadline_exceeded, unlike the
same deadline on the chain's first read. Wrap both errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-block: the intent page re-read sees only data the filer already freed

The filer frees a deleted entry's chunks, and the chunks an update drops,
from its deletion queue: polled every 1.123 s, and retried after 5 min
when a volume server does not answer. A stale update that puts such a
reference on an adopted page therefore reads back intact while the
deletion is still queued, and the intent publishes over data that is
freed moments later. The intact-bytes twin publishes for that reason.
State that bound in INV-SNAPSHOT-DELETE-ADOPT-002 and at the guard
instead of "changed or vanished ... refuses the publication".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-block: the delete intent publication row and diagram carry the re-read

Part C rule 2 moves a changed guard's Part A row and diagram with it.
The publication row now names the re-read after adoption and
INV-SNAPSHOT-DELETE-ADOPT-002, and the M9 diagram gains the transition's
idle and snap self-loops, which it lacked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-block: red: a stale adoption or mark lands on a re-created object

A metadata change writes the looked-up entry back, chunks included,
conditional only on its tags: paused between its lookup and its update, it
lands on an object deleted and created again with the same tags in between,
puts the deleted object's chunk on it, and a cleaner's stale mark then
deletes it. The filer's IF_CHUNKS_EQUAL condition refuses such a write.

This commit adds the plumbing and the tests, not the guard itself:
- the filer protocol subset gains WriteCondition (IF_CHUNKS_EQUAL) on
  UpdateEntryRequest; SWFS sends it through UpdateEntryIfChunks, and the
  fakes evaluate it (or drop it, as an older filer does);
- a startup probe sends a mismatched conditional update to the disposable
  probe HEAD; only a definite refusal turns the guard on for the stores the
  catalog opens. The startup log and /status/chunk (metadata_guard) name it.
The two guard tests fail here: changeMeta does not send the condition yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-block: metadata changes send the filer's chunk condition

With the guard on (the startup probe saw the filer enforce it), an
adoption or mark sends IF_CHUNKS_EQUAL with the looked-up entry's chunk
fids. A re-created object always has a new chunk, so a stale whole-entry
write is refused instead of putting a deleted object's chunk on it; a
cleaner's delete expects its own mark and so follows. Without the guard
the write is unchanged and the intent page re-read stays the check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-block: ledger rows for the chunk condition and its probe

INV-LAYOUT-META-CHUNKS-001 (adoption and mark under IF_CHUNKS_EQUAL) and
INV-WS-CHUNK-CONDITION-PROBE-001 (the startup probe decides it, the log
and /status/chunk name it); ADOPT-002 names the renamed store test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-block: the chunk probe without a definite refusal leaves the guard off; fallback wording

Review: the existing failure cases stop at the HEAD gate. New cases pass
the gate and then fail only the chunk condition probe (unavailable, lost,
deadline, filer error, vanished entry, failed HEAD read): the catalog, its
stores, the startup log and the usage all stay on page_reread_only.
page_reread_only now reads as enforcement not established, not as a filer
without the condition; INV-SNAPSHOT-DELETE-ADOPT-002 cites MetaABA r2's
delayed-free counterexample, r1 kept as historical scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
2026-12-05 11:29:24 -08:00
..