pingqiuandClaude Opus 5.5 8f56445ff3 storage: a failed WAL append is sticky for the open walstore
A batch append whose pwrite left its records on disk and then failed kept
nextLSN and the head, so the next write reused the batch's first LSN and
offset; the batch's later record survived past it, and after that write's
acknowledged Sync and a crash recovery replayed the stale record over it.

An append that fails while writing (marked errWALPwrite by the WAL writer:
the record or padding pwrite, single or batch) now latches the store's
I/O fault as ErrAppendFailed, wrapped in a SubstrateIO RecoveryFailure
(io_error), on the same latch as a failed fsync. Until the store is
reopened it refuses further appends and Syncs, so no LSN or offset is
reused. Space and encoding refusals, which write nothing, do not latch. A
reopen may replay the failed, never-acknowledged records.

Tests that continued on the same open store after a failed append now
assert the refusal and a reopen; the two chunk-layer tests that used a
failed append only to leave a newer record for a same-open Recover now
write that record past the head directly.

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