Files
seaweedfs/weed/storage
Chris LuandClaude Opus 5.5 f3b838e234 ec: encode past deletes a replica missed while it was down (#12879)
* volume_replica: encode past deletes a replica missed

A delete that reaches only some replicas, for example while one is
down, leaves that replica holding the needle live. The encoder's idx
gate then refused the volume forever.

A needle live on one replica and tombstoned on another by a record
appended after that write is a delete the first replica missed.
MissedDeletes finds them; the gate leaves them out of the live-set
comparison and encodes from a replica that holds none of them, so the
EC volume does not bring them back. A tombstone older than the live
write, a needle absent on the other side, and volumes without
AppendAtNs still refuse, as does a volume where every replica missed
some delete.

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

* erasure_coding: test encoding a volume one replica missed a delete on

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

* volume_replica: prove a missed delete from one replica's own index

AppendAtNs comes from each server's own clock, and vacuum's makeupDiff
re-stamps tombstones it carries over with the commit time, so comparing
a tombstone's AppendAtNs against another replica's write can order a
later rewrite before an older delete.

Prove the delete instead from the replica that applied it: its .idx
shows the live row the tombstone replaced, and when that record has the
same cookie, CRC and last-modified time as the needle still live on the
other replica, that very write was deleted. Replicated writes share all
three, a rewrite does not. A tombstone with no earlier write row (its
write vacuumed away) proves nothing and still refuses.

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

* volume_replica: test a missed delete with a third replica holding no row

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

* volume_replica: never count a needle its own replica deleted as missed

A same-content upload with the same ts after both replicas deleted the
needle matches the deleted write on cookie, CRC and last-modified. The
replica holding it has its own tombstone for the needle before that
live row, which a replica that missed the delete never has, so skip it.

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

* volume_replica: count a missed delete only for a needle written once

An overwrite that keeps cookie, CRC and last-modified, such as a TTL
volume re-append or a client-set ts, also matches the write another
replica deleted. A replica whose own index replaced an earlier row for
the needle, by an overwrite or by its own delete, may hold a write made
after that delete, so it never counts as having missed it.

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

* ec: compare capacity replicas first so a clean one is the encode source

When the preferred replica missed a delete, the gate falls back to the
first replica that holds none, and that could be one without the free
slots RequireCapacitySource needs, failing the encode although another
capacity replica was clean.

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

* volume_replica: keep the row an offset-0 delete removes as an earlier write

A remote-tier delete writes an offset-0 row and drops the key, so a later
identical rewrite looked written once and could count as a missed delete.

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

* volume_replica: refuse a missed delete whose live write is not older than the tombstone

Compaction keeps only the latest row per needle, so a same-meta rewrite
after the delete can lose the earlier row that marked it as rewritten.
Its record still carries its own append time, which then is not older
than the tombstone. The index proof still decides; the clocks only refuse.

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

* volume_replica: count a missed delete only when both replicas appended the write together

Compaction can drop the rows that show a replica rewrote a needle, and the
tombstone stamp is not a reliable delete time: a vacuum commit stamps
deletes made during the copy with the commit time, and replicas stamp with
their own clocks. A replicated write lands on every replica within the
forwarding time plus clock skew, so the live write and the deleted write
must also be stamped within a minute of each other.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:00:28 -08:00
..