pingqiuandClaude Opus 5.5 b91b2bf3b3 storage: a staged chunk is reused only while its mutation count is unchanged; a barrier Sync failure settles staged intents
The chunk's highest write LSN is not a change detector: a replica apply
may land a block at an LSN below another block of the same chunk, so the
maximum does not move and a stale stage could be reused. Each chunk now
has a mutation count, raised after every dirty-map insert (a write, a
batch write, a replica apply at any LSN) and every BASE block; flushing
moves bytes without changing them and never counts. It is an atomic
per-chunk counter on the write path (O(1), lock-free), sampled before the
staging read and compared at the barrier.

A barrier Sync failure after staging is a clean abort: the cut's staging
intents are deleted (a failed delete is kept and retried by the next cut).

Real-caller controls:
- chunk 0 holds a@10 and b@5; after the staging read, ApplyEntry(b, 6)
  through the production apply path, in the WAL and flushed: HEAD at H
  has b@6;
- staged uploads, then the local fsync fails at the barrier: no intent
  is left; with the intent delete failing too, the intent is kept and the
  next cut settles it and publishes the exact image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 11:52:01 -08:00
Languages
Go 84.5%
Rust 7.9%
Shell 2.7%
templ 1.6%
Java 1%
Other 2%