storage: the recovery fence punches holes, and a repeat is skipped

Every recovery zeroed the whole WAL range with pwrites and fsynced it:
the WAL's size in writes on every open, twice on a new volume. On Linux,
with the default sparse allocation, the fence now deallocates the range
(a hole punch, which reads zeros) and then fsyncs; where the filesystem
cannot punch, or off Linux, or on a prezeroed store, it writes zeros as
before. A recovery skips the fence when the same range was fenced and
fsynced in this open by the same writer with no WAL write since (a new
volume's second recovery). The fence's bytes count only after its fsync:
status reports FencePunched, FenceZeroed and FenceSkips.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-12-02 00:23:43 -08:00
1 parent 43c7f9eb1e
commit fcb5f608ac
10 files changed
+280 -4

No files matched your search

@@ -34,6 +34,9 @@ type CheckpointPersistenceStatus struct {
CycleExtentBytes uint64 // extent bytes the cycle in progress (or the latest) has written
LastExtentWrite time.Time // when the flusher last wrote extent bytes; zero if never in this open
CheckpointSteps CheckpointStepStatus // the checkpoint's step in progress and its per-step time, count and bytes
FencePunched uint64 // WAL fence bytes deallocated by hole punching in this open, counted after the fsync
FenceZeroed uint64 // WAL fence bytes written as zeros in this open (no hole punching), counted after the fsync
FenceSkips uint64 // recovery fences skipped: the same range was fenced in this open with no WAL write since
}
// ReclaimProgress is the flusher's reclaim progress for a write waiting for
@@ -77,6 +80,9 @@ func (s *WALStore) CheckpointPersistence() CheckpointPersistenceStatus {
FlusherPhase: i.phaseName(),
CycleExtentBytes: i.cycleExtentBytes.Load(),
CheckpointSteps: s.ckpt.status(),
FencePunched: s.fencePunchedBytes.Load(),
FenceZeroed: s.fenceZeroBytes.Load(),
FenceSkips: s.fenceSkips.Load(),
}
if ns := i.checkpointLastAdvanceNanos.Load(); ns != 0 {
st.LastAdvance = time.Unix(0, ns)
@@ -0,0 +1,21 @@
//go:build linux
package storage
import (
"errors"
"os"
"golang.org/x/sys/unix"
)
// punchHole deallocates [off, off+n) of f, keeping its size: the range reads
// zeros afterwards. The caller fsyncs.
func punchHole(f *os.File, off, n int64) error {
return unix.Fallocate(int(f.Fd()), unix.FALLOC_FL_PUNCH_HOLE|unix.FALLOC_FL_KEEP_SIZE, off, n)
}
// punchUnsupported reports a filesystem or kernel without hole punching.
func punchUnsupported(err error) bool {
return errors.Is(err, errFencePunchUnsupported) || errors.Is(err, unix.EOPNOTSUPP) || errors.Is(err, unix.ENOSYS)
}
@@ -0,0 +1,13 @@
//go:build !linux
package storage
import (
"errors"
"os"
)
// punchHole is unsupported off Linux: the fence writes zeros instead.
func punchHole(*os.File, int64, int64) error { return errFencePunchUnsupported }
func punchUnsupported(err error) bool { return errors.Is(err, errFencePunchUnsupported) }
+9
View File
@@ -45,6 +45,14 @@ type walWriterV3 struct {
// only the trusted kept prefix; a batch is one indivisible point.
reclaim []walReclaimPointV3
instr *writeInstrumentation
writes uint64 // WAL region writes by this writer (a fence that saw no write since need not repeat)
}
// writeCountV3 is how many WAL region writes this writer made.
func (w *walWriterV3) writeCountV3() uint64 {
w.mu.Lock()
defer w.mu.Unlock()
return w.writes
}
type walReclaimPointV3 struct{ lastLSN, end uint64 }
@@ -140,6 +148,7 @@ func (w *walWriterV3) append(e walEntryV3, durableLSN uint64, budget func() erro
}
write := func(b []byte, pos uint64) error {
start := time.Now()
w.writes++
n, err := w.writeAt(b, int64(d.WALOffset+pos%d.WALSize))
if w.instr != nil {
w.instr.recordWALAppend(n, time.Since(start))
+3
View File
@@ -90,6 +90,9 @@ type WALStore struct {
lastStop atomic.Pointer[StoreStopPhases]
closedCheckpoint atomic.Pointer[MapCheckpointPhases]
ckpt checkpointSteps // the flusher checkpoint's per-step timing
fencePunchedBytes atomic.Uint64 // WAL fence bytes deallocated (hole punch), counted after the fsync
fenceZeroBytes atomic.Uint64 // WAL fence bytes written as zeros, counted after the fsync
fenceSkips atomic.Uint64 // fences skipped: the same range was fenced in this open with no WAL write since
testDestructiveSnapshot func() // nil scheduling control, before any capture lock
testCloseSnapshot func() // nil in production; called without captureMu
@@ -0,0 +1,152 @@
package storage
import (
"bytes"
"os"
"path/filepath"
"runtime"
"testing"
)
// The fence on both of its paths: hole punching (Linux, sparse) and zero
// writes (no punching). On each, records dropped by one recovery do not
// resurface after a second crash.
func TestWALStoreV3FenceBothPathsReplayNoStaleRecord(t *testing.T) {
for _, path := range []string{"punch", "zero"} {
t.Run(path, func(t *testing.T) {
if path == "zero" {
punchHoleFn = func(*os.File, int64, int64) error { return errFencePunchUnsupported }
t.Cleanup(func() { punchHoleFn = punchHole })
}
for _, mode := range []WMode{WModeLagged, WModeStrict} {
if resurrectionSchedule(t, mode, false) {
t.Fatalf("%s fence, mode %d: a record dropped by recovery resurfaced after the second crash", path, mode)
}
}
})
}
}
// The fence counts its bytes after the fsync, by path; a repeated recovery
// with no WAL write since skips the fence (a new volume's second recovery),
// and one after a write fences again.
func TestWALStoreV3FenceCountsAndSkipsARepeat(t *testing.T) {
for _, path := range []string{"punch", "zero"} {
t.Run(path, func(t *testing.T) {
if path == "zero" {
punchHoleFn = func(*os.File, int64, int64) error { return errFencePunchUnsupported }
t.Cleanup(func() { punchHoleFn = punchHole })
}
const walSize = 256 * 1024
s, err := createMappedWALStoreV3ForTest(filepath.Join(t.TempDir(), "volume"), 64, 4096, walSize, WModeLagged, 4)
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = s.Close() })
s.DisableAutoFlushForRecoveryTest()
if _, err := s.Recover(); err != nil {
t.Fatal(err)
}
first := s.CheckpointPersistence() // creation recovers once, then this Recover
fenced := first.FencePunched + first.FenceZeroed
if fenced != walSize {
t.Fatalf("a new store's first recovery fenced %d bytes, want the whole WAL %d: %+v", fenced, walSize, first)
}
punchExpected := path == "punch" && runtime.GOOS == "linux"
if punchExpected != (first.FencePunched == walSize) || (!punchExpected && first.FenceZeroed != walSize) {
t.Fatalf("%s path on %s: punched=%d zeroed=%d", path, runtime.GOOS, first.FencePunched, first.FenceZeroed)
}
if _, err := s.Recover(); err != nil {
t.Fatal(err)
}
second := s.CheckpointPersistence()
if second.FenceSkips != first.FenceSkips+1 || second.FencePunched+second.FenceZeroed != fenced {
t.Fatalf("a repeated recovery with no WAL write: skips=%d fenced %d -> %d", second.FenceSkips, fenced, second.FencePunched+second.FenceZeroed)
}
if _, err := s.Write(1, blk(1)); err != nil {
t.Fatal(err)
}
if _, err := s.Sync(); err != nil {
t.Fatal(err)
}
if _, err := s.Recover(); err != nil {
t.Fatal(err)
}
third := s.CheckpointPersistence()
if third.FenceSkips != second.FenceSkips || third.FencePunched+third.FenceZeroed <= fenced {
t.Fatalf("a recovery after a WAL write must fence again: %+v", third)
}
})
}
}
// A same-open recovery whose head did not move still fences when the WAL
// region was written since the last fence: here records 4 and 5 were
// appended and 4 is torn, so the head stays at 3 while 5 still sits behind
// it. Skipping that fence (the same range key) would let 5 resurface once a
// new record of 4's size refills its place and the store crashes.
func TestWALStoreV3SameOpenRecoveryAfterWritesStillFences(t *testing.T) {
s, path := newStoreV3(t, WModeLagged)
writeSynced(t, s, 1, 3)
if _, err := s.Recover(); err != nil { // fences at head 3
t.Fatal(err)
}
for _, lba := range []uint32{4, 5} {
if _, err := s.Write(lba, blk(byte(lba))); err != nil {
t.Fatal(err)
}
}
damageOpenRecord(t, s, 4)
skips := s.CheckpointPersistence().FenceSkips
if _, err := s.Recover(); err != nil { // head 3 again: the same range key
t.Fatal(err)
}
skipped := s.CheckpointPersistence().FenceSkips != skips
if bytes.Equal(readV3(t, s, 5), blk(5)) {
t.Fatal("the recovery kept LSN 5 above the torn 4")
}
if _, err := s.Write(9, blk(0x99)); err != nil { // refills 4's place, same size
t.Fatal(err)
}
if _, err := s.Sync(); err != nil {
t.Fatal(err)
}
crashRecoveryHardeningStore(t, s)
r := mustReopenV3(t, path)
defer r.Close()
if bytes.Equal(readV3(t, r, 5), blk(5)) {
t.Fatalf("a record dropped by a same-open recovery resurfaced after the crash (its fence skipped: %v)", skipped)
}
if skipped {
t.Fatal("a recovery after WAL writes skipped its fence")
}
}
// damageOpenRecord flips one payload byte of the WAL record carrying lsn
// through the open store's own file (no second handle, which a locked file
// refuses on Windows).
func damageOpenRecord(t *testing.T, s *WALStore, lsn uint64) {
t.Helper()
d := s.v3.pub.current()
r, err := scanWALV3(s.fd, d)
if err != nil {
t.Fatal(err)
}
for _, rec := range r.Records {
if rec.Entry.LSN != lsn {
continue
}
size := uint64(walEntryHeaderSizeV3 + len(rec.Entry.Data))
off := int64(d.WALOffset+(rec.End-size)%d.WALSize) + walEntryPrefixSizeV3 + 100
x := []byte{0}
if _, err := s.fd.ReadAt(x, off); err != nil {
t.Fatal(err)
}
x[0] ^= 0xFF
if _, err := s.fd.WriteAt(x, off); err != nil {
t.Fatal(err)
}
return
}
t.Fatalf("no WAL record with LSN %d", lsn)
}
+66 -2
View File
@@ -27,6 +27,7 @@ import (
// migration tool or restore into a newly created volume. BASE mutations use
// install handles; raw extent writes and frontier jumps remain refused.
type walStoreV3State struct {
lastFence *fenceRecordV3 // the last completed fence in this open (recovery only)
// layoutFresh mirrors the descriptor's layout identity: set while the
// local root is fresh, when no guest write may be acknowledged.
layoutFresh atomic.Bool
@@ -191,6 +192,24 @@ func probeWALStoreV3At(r io.ReaderAt) error {
// tests.
var testSkipFenceOnRecoverV3 bool
// punchHoleFn is punchHole; tests replace it to force the zero-write path.
var punchHoleFn = punchHole
// errFencePunchUnsupported is a hole punch the platform cannot do: the
// fence writes zeros instead.
var errFencePunchUnsupported = errors.New("storage: hole punching unsupported")
// fenceRecordV3 is the last completed fence: its range key, and the writer
// and that writer's WAL write count when it completed. A fence with the same
// key, the same writer and no WAL write since would change no byte.
type fenceRecordV3 struct {
nonce [16]byte
E, floor, walSize uint64
walOffset uint64
writer *walWriterV3
writesAtFence uint64
}
// FormatV3 reports whether the store uses the v3 format.
func (s *WALStore) FormatV3() bool { return s.v3 != nil }
@@ -773,10 +792,46 @@ func (s *WALStore) fenceV3(E, floor, walSize uint64, sameNonce bool, walOffset u
if len(ranges) == 0 || testSkipFenceOnRecoverV3 {
return nil
}
return s.syncFile(func() error {
v := s.v3
rec := fenceRecordV3{nonce: v.pub.current().Nonce, E: E, floor: floor, walSize: walSize, walOffset: walOffset, writer: v.w}
if last := v.lastFence; last != nil && rec.writer != nil && last.writer == rec.writer &&
last.nonce == rec.nonce && last.E == E && last.floor == floor && last.walSize == walSize && last.walOffset == walOffset &&
rec.writer.writeCountV3() == last.writesAtFence {
// The same range was fenced and fsynced in this open, and nothing has
// written the WAL region since: the fence would change no byte (a new
// volume's second recovery).
s.fenceSkips.Add(1)
return nil
}
if rec.writer != nil {
rec.writesAtFence = rec.writer.writeCountV3()
}
mode, err := configuredAllocationMode()
if err != nil {
return err
}
punch := mode == "sparse" // a prezeroed store stays allocated: zero writes
var punched, zeroed uint64
err = s.syncFile(func() error {
const chunk = 64 * 1024
zero := make([]byte, chunk)
var zero []byte
for _, r := range ranges {
if punch {
perr := punchHoleFn(s.fd, int64(walOffset+r.Off), int64(r.Len))
if perr == nil {
punched += r.Len
continue
}
if !punchUnsupported(perr) {
perr = fmt.Errorf("storage: v3 drop fence: %w", perr)
s.latchV3(perr)
return perr
}
punch = false // the filesystem cannot punch: zeros from here on
}
if zero == nil {
zero = make([]byte, chunk)
}
for done := uint64(0); done < r.Len; {
n := min(r.Len-done, chunk)
if _, err := s.fd.WriteAt(zero[:n], int64(walOffset+r.Off+done)); err != nil {
@@ -786,9 +841,18 @@ func (s *WALStore) fenceV3(E, floor, walSize uint64, sameNonce bool, walOffset u
}
done += n
}
zeroed += r.Len
}
return nil
}, s.fd.Sync)
if err != nil {
return err
}
// The fence counts only after its fsync.
s.fencePunchedBytes.Add(punched)
s.fenceZeroBytes.Add(zeroed)
v.lastFence = &rec
return nil
}
// appendWriteV3 is the v3 body of Write's append, under s.mu. DurableLSN is
+3 -2
View File
@@ -79,7 +79,7 @@ stateDiagram-v2
| — | CreateRefused | a chunk volume in create mode (no local store yet): before the provider is built, the geometry flags are compared with the volume record; they disagree, or the record is there but does not decode: exit 78; the filer failed the read: exit 75; nothing is created; an absent record keeps the create path; an existing store is never rechecked against the flags | `cmd/blockvolume/main.go` (create-mode check); `cmd/blockvolume/chunk_remote.go` `geometryFlagsRefusal` | `INV-VOL-GEOMETRY-FLAGS-RECORD-001` |
| — | OpenRefused | the file's header carries a removed experimental engine's magic (smartwal, parallel-walstore): refused typed under every selector, read-only, never modified | `core/frontend/durable/provider.go` `verifyImplOnDisk` | `INV-OPEN-REMOVED-ENGINE-REFUSED-001` |
| Opened | Recovering | the volume is open in the provider | `core/frontend/durable/provider.go` `RecoverVolume` | `INV-WAL-OPGATE-001`, `INV-RECOVERY-PROGRESS-WINDOW-001` |
| Recovering | Serving | v3 nonce/cursor-bound physical prefix satisfies its W/BASE gate; rollback fence and rebuilt bounds publish before reuse; `Recover` aborts/drains an open COW window before lower locks, holds the capture barrier and invalidates proofs at start/end; the frontend targets start, and `FrontendPrimaryReady` is reported, only once the backend admits I/O (a chunk volume: after its storage claim; attach-pending or fenced reports not ready with the reason); a workspace primary claims HEAD, listens and reports ready only while its lease guard permits now (`WorkspaceLeaseGuard.Held`; without a grant: `NotReadyReason=lease_not_held`, exit 75 after the start-time wait); a primary of a replicated line serves only when its own `--replication-ack` is the profile its assignment names (otherwise not Healthy, `NotReadyReason` naming both profiles, ahead of the backend's own refusal) | `core/storage/walstore_v3.go` `recoverV3`; `core/storage/walstore.go` `WALStore.Recover`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `core/host/volume/status_server.go` `statusProjection`; `core/host/volume/workspace_lease.go` `Held`; `core/host/volume/workspace_startup.go` `noteAckProfile` | `INV-WAL-SYNCED-RECOVERED-001`, `INV-WAL-REPLAY-LWW-001`, `INV-WAL-FRONTIER-GAP-001`, `INV-CUT-RECOVER-BARRIER-001`, `INV-WAL-V3-W-RECOVERY-001`, `INV-WAL-V3-FENCE-001`, `INV-WAL-V3-MAP-PUBLISH-001`, `INV-FE-PRIMARY-READY-OPERATIONAL-001`, `INV-WS-SERVE-LEASE-HELD-001`, `INV-PRIMARY-ACK-PROFILE-001`, `INV-ATTACH-ASSIGNMENT-BOUND-001`, `INV-LAYOUT-REMOTE-CAPABILITIES-001` |
| Recovering | Serving | v3 nonce/cursor-bound physical prefix satisfies its W/BASE gate; rollback fence and rebuilt bounds publish before reuse; `Recover` aborts/drains an open COW window before lower locks, holds the capture barrier and invalidates proofs at start/end; the frontend targets start, and `FrontendPrimaryReady` is reported, only once the backend admits I/O (a chunk volume: after its storage claim; attach-pending or fenced reports not ready with the reason); a workspace primary claims HEAD, listens and reports ready only while its lease guard permits now (`WorkspaceLeaseGuard.Held`; without a grant: `NotReadyReason=lease_not_held`, exit 75 after the start-time wait); a primary of a replicated line serves only when its own `--replication-ack` is the profile its assignment names (otherwise not Healthy, `NotReadyReason` naming both profiles, ahead of the backend's own refusal) | `core/storage/walstore_v3.go` `recoverV3`; `core/storage/walstore.go` `WALStore.Recover`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `core/host/volume/status_server.go` `statusProjection`; `core/host/volume/workspace_lease.go` `Held`; `core/host/volume/workspace_startup.go` `noteAckProfile` | `INV-WAL-SYNCED-RECOVERED-001`, `INV-WAL-REPLAY-LWW-001`, `INV-WAL-FRONTIER-GAP-001`, `INV-CUT-RECOVER-BARRIER-001`, `INV-WAL-V3-W-RECOVERY-001`, `INV-WAL-V3-FENCE-001`, `INV-WAL-V3-FENCE-PUNCH-001`, `INV-WAL-V3-MAP-PUBLISH-001`, `INV-FE-PRIMARY-READY-OPERATIONAL-001`, `INV-WS-SERVE-LEASE-HELD-001`, `INV-PRIMARY-ACK-PROFILE-001`, `INV-ATTACH-ASSIGNMENT-BOUND-001`, `INV-LAYOUT-REMOTE-CAPABILITIES-001` |
| Recovering | Serving (v1.1 upgrade, clean-stop seed) | the chunk layer attaches an unmarked store on the draft v1.1 format (lab builds only), after Recover and the storage claim: each whole local chunk is written Rebuilt all → U, Hash → HU, Commit → HP with HEAD's hash (a chunk HEAD does not name: the zero chunk's) only when all hold: a clean-stop proof (the HEAD the claim was built on was a committed, idle detach, `DetachedBy`), its claim id is the store's layout claim id, and its position is the store's synced position the pages are valid through; otherwise each whole local chunk is U (left to the compare pass); partial and absent chunks are classified alike in both; a marked store never seeds | `core/frontend/chunkstore/layout/start.go` `Start` (`ReportCleanStop`); `core/frontend/durable/provider_layout.go` `startLayoutRoot`; `core/storage/chunk_record_upgrade.go` `upgradeChunkRecordSeeded`, `seedsLineage`, `cleanStopHashes` | `INV-CHUNK-RECORD-SEED-001`, `INV-CHUNK-RECORD-UPGRADE-001` |
| Recovering | RecoveryFailed | a WAL integrity failure or an I/O error; the backend stays not operational and the host blocks local readiness with `wal_corrupt` or `io_error` | `cmd/blockvolume/durable_startup.go` `openAndRecoverDurable`; `core/host/volume/recovery_watchdog.go` `LocalRecoveryHealthReason` | `INV-WAL-TYPED-FAILCLOSED-001`, `INV-WAL-OPGATE-001`, `INV-WAL-V3-W-RECOVERY-001` |
| Serving | Serving | each `Read`, `Write`, `Sync` passes the operational, chunk-fence and lineage checks; write admission samples the active writer's native pressure before waiting; a write is durable only when a covering `Sync` returns | `core/frontend/durable/storage_adapter.go` `gate`; `core/storage/walstore.go` `WALStore.Sync` | `INV-FE-LINEAGE-GATE-001`, `INV-WAL-SYNC-FRONTIER-001`, `INV-FE-FUA-SYNC-001`, `INV-FE-FLUSH-SYNC-001`, `INV-WAL-V3-ADMISSION-001`, `INV-WAL-V3-W-001` |
@@ -722,7 +722,8 @@ The "Machine / transition" column refers to Part A. Notes under a table record w
| `INV-WAL-V3-W-CHECKPOINT-CLAMP-001` | A v3 checkpoint never exceeds the acknowledged W; entries the flusher wrote to the extent above the published checkpoint stay retry work, so a later Sync and flusher cycle advance the checkpoint and map coverage together. | M1 write lifecycle: InExtent → Checkpointed (v3) | `core/storage/walstore_v3.go` `WALStore.persistCheckpointV3`; `core/storage/walstore_map_checkpoint_v3.go` `WALStore.persistOwnedMapCheckpointV3`; `core/storage/flusher.go` `flushOnceInternal` | `TestWALStoreV3FlusherCheckpointIsClampedToTheAcknowledgedW`, `TestWALStoreV3FlusherWritesTheExtentButHoldsTheCheckpointUntilTheMap` (`core/storage/walstore_v3_test.go`); `TestWALStoreV3_FlushedProgressRetriesAfterLaterSync` (`core/storage/walstore_flushed_progress_v3_test.go`) | — | STUB |
| `INV-WAL-V3-W-SETWMODE-001` | `SetWMode` first syncs every write admitted before it under the old mode, then publishes the new mode while holding the v3 leader role, so no Sync batch acknowledges under a mode other than the descriptor's. | M1 write lifecycle: Appended → Synced (v3) | `core/storage/walstore_v3.go` `WALStore.SetWMode`, `WALStore.syncWALBatchV3Internal` | `TestWALStoreV3SetWModeWaitsForAHeldBatch`, `TestWALStoreV3NoBatchAcksUnderAStaleModeAfterSetWMode`, `TestWALStoreV3SetWModeCrashCases` (`core/storage/walstore_v3_test.go`) | — | DORMANT |
| `INV-WAL-V3-W-RECOVER-STRADDLE-001` | No v3 W publication or Sync acknowledgement straddles a recovery: a Sync whose completion sees a changed recovery generation is refused, and recovery sets the acknowledged W to its recovered prefix R. | M1 Recovering → Serving | `core/storage/walstore_v3.go` `WALStore.recoverV3`, `WALStore.refreshW`, `WALStore.syncWALBatchV3Internal`; `core/storage/walstore.go` `WALStore.syncWithPhases` | `TestWALStoreV3SameOpenRecoverResetsTheAcknowledgedFrontier`, `TestWALStoreV3RecoverWaitsForABatchAckAndNothingRevivesTheCut`, `TestWALStoreV3OuterSyncCompletionIsRefusedAcrossARecovery`, `TestWALStoreV3RefreshDuringRecoverWaitsAndPublishesNothing` (`core/storage/walstore_v3_test.go`) | — | STUB |
| `INV-WAL-V3-FENCE-001` | Before any append after a v3 recovery, the store zeroes the logical WAL interval [E, floor + WALSize), floor being the both-slot same-nonce reuse floor, fsyncs it through the leaf, and only then publishes retainedHead = E. | M1 Recovering → Serving (v3) | `core/storage/walstore_v3.go` `WALStore.recoverV3`, `WALStore.fenceV3`; `core/storage/recovery_v3.go` `fenceRangesV3` | `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestWALStoreV3NoFenceResurrectsInBothModes` (`core/storage/walstore_v3_test.go`) | `WALFormat` `NoResurrection` | STUB |
| `INV-WAL-V3-FENCE-PUNCH-001` | The fence deallocates its range (a hole punch, which reads zeros) on a sparse store where the filesystem can, else writes zeros; a recovery skips the fence only when the same range was fenced and fsynced in this open with no WAL write since. | M1 Recovering → Serving (v3) | `core/storage/walstore_v3.go` `WALStore.fenceV3`; `core/storage/fence_punch_linux.go` `punchHole`; `core/storage/wal_io_v3.go` `writeCountV3` | `TestWALStoreV3FenceBothPathsReplayNoStaleRecord`, `TestWALStoreV3FenceCountsAndSkipsARepeat`, `TestWALStoreV3SameOpenRecoveryAfterWritesStillFences` (`core/storage/walstore_fence_punch_v3_test.go`) | `WALFormat` `NoResurrection` | ACTIVE |
| `INV-WAL-V3-FENCE-001` | Before any append after a v3 recovery, the store zeroes the logical WAL interval [E, floor + WALSize), floor being the both-slot same-nonce reuse floor, fsyncs it through the leaf, and only then publishes retainedHead = E. | M1 Recovering → Serving (v3) | `core/storage/walstore_v3.go` `WALStore.recoverV3`, `WALStore.fenceV3`; `core/storage/recovery_v3.go` `fenceRangesV3` | `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestWALStoreV3NoFenceResurrectsInBothModes` (`core/storage/walstore_v3_test.go`); `TestWALStoreV3FenceBothPathsReplayNoStaleRecord` (`core/storage/walstore_fence_punch_v3_test.go`) | `WALFormat` `NoResurrection` | STUB |
| `INV-WAL-V3-FENCE-EXACT-001` | The v3 drop fence changes only the bytes of [E, floor + WALSize) mapped modulo WALSize, in at most two ranges split at the physical wrap; no byte before E or outside the interval changes. | M1 Recovering → Serving (v3) | `core/storage/recovery_v3.go` `fenceRangesV3`; `core/storage/walstore_v3.go` `WALStore.fenceV3` | `TestWALStoreV3FenceTouchesNoByteBeforeTheHead`, `TestWALStoreV3RecoversAHistoryEndingAtTheLastRepresentableCursor` (`core/storage/walstore_v3_test.go`); `TestRecoveryV3FenceRangesAreExact` (`core/storage/recovery_v3_test.go`) | — | STUB |
| `INV-WAL-V3-NO-RESURRECTION-001` | A WAL record dropped by one v3 recovery is never replayed by a later recovery, also after a second crash. | M1 Recovering → Serving (v3) | `core/storage/walstore_v3.go` `WALStore.recoverV3`, `WALStore.fenceV3`; `core/storage/wal_io_v3.go` `scanWALV3Accepted` | `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestWALStoreV3NoFenceResurrectsInBothModes` (`core/storage/walstore_v3_test.go`) | `WALFormat` `NoResurrection` | STUB |
| `INV-WAL-V3-RESET-001` | A v3 nonce/position reset is refused with `ErrResetNotPreserved`, writing nothing, unless the dirty map is empty and CheckpointLSN is at least every appended LSN (and so equals the acknowledged W). | M1 Serving → Serving (reset: no production caller; tests only) | `core/storage/reset_v3.go` `WALStore.resetIncarnationV3`, `descriptorPublisherV3.resetIncarnationV3` | `TestResetV3RefusesWhileUncheckpointed`, `TestResetV3RetainedButCheckpointedBytesDoNotBlock` (`core/storage/reset_v3_test.go`); `TestWALStoreV3ResetRefusesUncheckpointedOrUnacknowledgedData` (`core/storage/reset_store_v3_test.go`) | `WALFormat` reset (r4.5, pending) | DORMANT |
+4
View File
@@ -29,6 +29,10 @@ These notes collect v1.1's changes as they land; v1.1 is not released.
write waiting for WAL space now sees space freed every step rather than once per whole-WAL cycle. Status reports
the reclaim progress in `CheckpointPersistence`: `ReclaimedBytes`, `BoundedCycles`, `FlusherPhase`,
`CycleStarted`, `CycleExtentBytes` and `LastExtentWrite`.
- Recovery's WAL fence no longer writes the whole WAL as zeros on every open: on Linux, with the default sparse
allocation, it deallocates the range (a hole punch, which reads as zeros), falling back to zero writes where the
filesystem cannot; a new volume's second recovery skips the fence its first one just made. Status counts the bytes
in `CheckpointPersistence.FencePunched`, `FenceZeroed` and `FenceSkips`.
## Upgrade
- With `--host-limit-dir` set, the limiter's `configuration.json` in that directory records the flags it was
+3
View File
@@ -225,6 +225,9 @@ Durable store state of the served volume. Go type `volume.durableStatusBody`.
| `Volumes[].CheckpointPersistence.CheckpointSteps.Nanos` | object | cumulative nanoseconds per step name |
| `Volumes[].CheckpointPersistence.CheckpointSteps.Count` | object | how many times each step ran |
| `Volumes[].CheckpointPersistence.CheckpointSteps.Bytes` | object | bytes each writing step wrote (map_write, slot_write) |
| `Volumes[].CheckpointPersistence.FencePunched` | uint64 | WAL fence bytes deallocated by hole punching in this open, counted after the fsync |
| `Volumes[].CheckpointPersistence.FenceZeroed` | uint64 | WAL fence bytes written as zeros in this open (no hole punching), counted after the fsync |
| `Volumes[].CheckpointPersistence.FenceSkips` | uint64 | recovery fences skipped: the same range was fenced in this open with no WAL write since |
| `Volumes[].Chunk` | object | Chunk is the chunk layer's state and cut counters; walstore-chunk volumes only. |
| `Volumes[].Chunk.CurrentCut` | object | active cut phase; absent when idle (omitted when empty) |
| `Volumes[].Chunk.CurrentCut.attempt_started_at` | time (RFC 3339) | start of the whole attempt, unchanged across phase visits |