storage: the WAL flusher reclaims in bounded cycles

A flusher cycle drained the whole dirty map before one fsync and one
checkpoint, so on a slow disk no WAL byte was freed until the cycle ended
and a write waiting for space timed out while reclaim was running. A
cycle now takes the LSN prefix of the synced entries that fits in a
sixteenth of the WAL, cut at a record boundary (a native batch's blocks
stay together), and checkpoints at its last LSN; the run loop starts the
next cycle at once while entries remain. A pass position moves each
cycle past the previous batch, so a checkpoint held below a batch does
not repeat it, and it is trusted only within one recovery lifetime. A
full drain runs cycles until its first frontier is drained.

The durable status's checkpoint persistence gains the reclaim counters
(ReclaimedBytes, BoundedCycles, FlusherPhase, CycleStarted,
CycleExtentBytes, LastExtentWrite), and WALStore.ReclaimProgress reads
them without a store lock for a write's hold path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-12-01 23:22:57 -08:00
1 parent 2f602b6a11
commit d6bf9aa03a
9 files changed
+582 -36

No files matched your search

@@ -14,13 +14,49 @@ import (
// this open), so a starved checkpoint shows Successes rising while
// LastAdvance stays frozen. Fields are cumulative atomic observations, not a
// coherent frontier.
//
// The reclaim fields tell slow reclaim from none: a write waiting for WAL
// space sees progress when the checkpoint advances (Advances, LastAdvance,
// ReclaimedBytes) or the cycle in progress writes extent bytes
// (CycleExtentBytes, LastExtentWrite); FlusherPhase says what the flusher is
// doing or waits on.
type CheckpointPersistenceStatus struct {
Successes uint64 // checkpoint calls that succeeded (including unchanged ones)
Refusals uint64 // checkpoint calls refused because the map coverage was stale
Failures uint64 // checkpoint calls that failed with an error
CheckpointLSN uint64 // the persisted checkpoint LSN
Advances uint64 // successes that moved CheckpointLSN forward
LastAdvance time.Time // when the latest advance happened; zero if none in this open
Successes uint64 // checkpoint calls that succeeded (including unchanged ones)
Refusals uint64 // checkpoint calls refused because the map coverage was stale
Failures uint64 // checkpoint calls that failed with an error
CheckpointLSN uint64 // the persisted checkpoint LSN
Advances uint64 // successes that moved CheckpointLSN forward
LastAdvance time.Time // when the latest advance happened; zero if none in this open
ReclaimedBytes uint64 // WAL bytes the checkpoint advances released in this open
BoundedCycles uint64 // flusher cycles that stopped at the batch bound (a sixteenth of the WAL) with entries left for the next
FlusherPhase string // idle, drain_held (before the chunk layer attaches), wal_sync (every dirty entry above the synced WAL), writing, extent_sync or checkpoint
CycleStarted time.Time // when the flusher cycle in progress started; zero when none is
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
}
// ReclaimProgress is the flusher's reclaim progress for a write waiting for
// WAL space. It reads atomics only, never a store lock, so it answers while a
// cycle or a publication holds one. A waiter sees progress when ReclaimedBytes
// or ExtentBytes moves.
type ReclaimProgress struct {
ReclaimedBytes uint64 // WAL bytes made reusable in this open: the moves of the same-nonce reuse floor (the lower of both descriptor slots' retained tails) at the flusher's checkpoints
Advances uint64 // checkpoint advances in this open
ExtentBytes uint64 // extent bytes the flusher wrote in this open
Phase string // the flusher's phase (CheckpointPersistenceStatus.FlusherPhase)
}
func (s *WALStore) ReclaimProgress() ReclaimProgress {
if s.flusher == nil {
return ReclaimProgress{Phase: flusherPhaseNames[flusherIdle]}
}
i := &s.flusher.instr
return ReclaimProgress{
ReclaimedBytes: i.reclaimedBytes.Load(),
Advances: i.checkpointAdvances.Load(),
ExtentBytes: i.extentWriteBytes.Load(),
Phase: i.phaseName(),
}
}
func (s *WALStore) CheckpointPersistence() CheckpointPersistenceStatus {
@@ -34,10 +70,21 @@ func (s *WALStore) CheckpointPersistence() CheckpointPersistenceStatus {
Failures: i.checkpointFailures.Load(),
CheckpointLSN: s.CheckpointLSN(),
Advances: i.checkpointAdvances.Load(),
ReclaimedBytes: i.reclaimedBytes.Load(),
BoundedCycles: i.boundedCycles.Load(),
FlusherPhase: i.phaseName(),
CycleExtentBytes: i.cycleExtentBytes.Load(),
}
if ns := i.checkpointLastAdvanceNanos.Load(); ns != 0 {
st.LastAdvance = time.Unix(0, ns)
}
if ns := i.cycleStartNanos.Load(); ns != 0 {
st.CycleStarted = time.Unix(0, ns)
}
if ns := i.lastExtentWriteNanos.Load(); ns != 0 {
st.LastExtentWrite = time.Unix(0, ns)
}
return st
}
@@ -56,7 +56,9 @@ func TestCheckpointDiagnostics_RefusalThenSuccess(t *testing.T) {
if err := json.Unmarshal(raw, &counts); err != nil {
t.Fatal(err)
}
if counts["CheckpointRefusals"] != 1 || counts["CheckpointSuccesses"] != 1 || s.CheckpointLSN() != 2 || s.dm.len() != 0 {
// The drain runs bounded cycles (a sixteenth of this small WAL is one
// block): one checkpoint success per cycle, each bounded cycle but the last.
if counts["CheckpointRefusals"] != 1 || counts["CheckpointSuccesses"] != s.CheckpointPersistence().BoundedCycles+1 || s.CheckpointLSN() != 2 || s.dm.len() != 0 {
t.Fatalf("retry counters/state: %s cp=%d", raw, s.CheckpointLSN())
}
}
@@ -163,7 +165,8 @@ func TestCheckpointDiagnostics_StarvedCheckpointIsVisible(t *testing.T) {
t.Fatal(err)
}
moved := s.CheckpointPersistence()
if moved.CheckpointLSN != s.CheckpointLSN() || moved.CheckpointLSN <= 1 || moved.Advances != 2 || !moved.LastAdvance.After(first.LastAdvance) {
// One advance per cycle of the drain (bounded cycles on this small WAL).
if moved.CheckpointLSN != s.CheckpointLSN() || moved.CheckpointLSN <= 1 || moved.Advances != first.Advances+1+moved.BoundedCycles-starved.BoundedCycles || !moved.LastAdvance.After(first.LastAdvance) {
t.Fatalf("after sync the checkpoint advance was not recorded: %+v", moved)
}
}
+147 -26
View File
@@ -2,6 +2,7 @@ package storage
import (
"fmt"
"math"
"sort"
"sync"
"sync/atomic"
@@ -31,14 +32,19 @@ import (
// matches what we flushed. A concurrent Write() that bumped
// the entry's LSN must NOT have its newer data lost.
//
// Note: V2 has no batch-size cutoff. The flusher processes the
// whole snapshot in one cycle. This was a deliberate V2 choice
// (perf-acceptable; correctness simpler). An earlier draft of
// this file added a `maxBatch` truncation; that truncation
// silently broke the checkpoint invariant — if the truncated
// portion contained entries with smaller LSNs, the checkpoint
// could advance past unflushed older records and recovery would
// later skip them. Removed.
// A cycle is bounded: it takes the LSN prefix of the synced entries whose
// data fits in a sixteenth of the WAL (boundCycleBatch), cut only at a record
// boundary (a native batch's blocks stay together), and the run loop starts
// the next cycle at once while entries remain. On a slow disk the checkpoint, and so the WAL space, then moves
// every bounded cycle instead of once per whole-map cycle (a guest write
// waiting for space sees reclaim progress). The prefix is what keeps the
// checkpoint invariant: checkpoint L means every record with LSN <= L is in
// the extent or superseded by a record of the same LBA with LSN > L, still in
// the WAL because L is below it. An earlier `maxBatch` truncation in an
// arbitrary order broke exactly that (it could leave an older record behind
// a newer checkpoint) and was removed; the synced-frontier filter below was
// already such a prefix. A full drain (flushOnce, the final flush of a stop)
// runs bounded cycles until its first frontier is drained.
type flusher struct {
store *WALStore // the local data process this flusher serves
interval time.Duration // upper bound on flush latency
@@ -62,6 +68,36 @@ type flusher struct {
afterExtentSyncForTest func()
// Pauses after checkpoint/reuse publication, before the outer DM cleanup.
afterCheckpointForTest func()
// Runs before each extent write of a cycle (a slow disk). Tests only.
beforeExtentWriteForTest func()
pass flushPass // the run loop's pass position; owned by the run loop
}
// flushPass is where a cycle starts within a pass over the dirty entries:
// entries with LSN in (after, limit]. A pass writes every entry once, in
// bounded cycles, even when the checkpoint is held below them (a recycle
// floor, retention, a map): the next cycle starts after the previous
// batch's last LSN, not at the oldest dirty entry, so a held batch is not
// repeated. after is meaningful only within the recovery lifetime gen: a
// Recover may reuse LSNs, and a cycle that sees another lifetime starts the
// pass over (after = 0).
type flushPass struct {
after, gen, limit uint64
}
// flushCycleResult is what one bounded cycle leaves: frontier is the synced
// WAL frontier it drained toward, last the batch's highest LSN, gen its
// recovery lifetime, and more reports entries in (last, frontier] that the
// batch bound left for the next cycle.
type flushCycleResult struct {
frontier, last, gen uint64
more bool
}
// next is the pass position after this cycle.
func (r flushCycleResult) next(limit uint64) flushPass {
return flushPass{after: r.last, gen: r.gen, limit: limit}
}
type flusherConfig struct {
@@ -121,11 +157,11 @@ func (f *flusher) runWithStartSignal(started chan<- struct{}) {
f.stopErr = f.flushOnceAllowClosed()
return
case <-ticker.C:
if err := f.flushOnce(); err != nil {
if err := f.cycle(); err != nil {
diagnostics.report(err, time.Now())
}
case <-f.notifyCh:
if err := f.flushOnce(); err != nil {
if err := f.cycle(); err != nil {
diagnostics.report(err, time.Now())
}
}
@@ -145,8 +181,24 @@ func (f *flusher) Stop() error {
func (f *flusher) FlushCount() uint64 { return f.flushes.Load() }
func (f *flusher) BytesFlushed() uint64 { return f.bytesOut.Load() }
// flushOnce performs one flush cycle. Returns nil if there was
// nothing to flush, or surfaces extent-write / fsync errors.
// cycle runs one bounded cycle for the run loop and, while entries at or
// below the synced frontier remain, wakes the loop for the next one at once;
// between cycles the loop still sees a stop. A pass that ends (or fails)
// starts the next one at the oldest dirty entry.
func (f *flusher) cycle() error {
r, err := f.flushCycle(false, f.pass)
f.pass = flushPass{limit: math.MaxUint64}
if err == nil && r.more {
f.pass = r.next(math.MaxUint64)
f.Notify()
}
return err
}
// flushOnce drains every entry at or below the synced WAL frontier that its
// first cycle observes, in bounded cycles. Returns nil if there was nothing
// to flush, or surfaces extent-write / fsync errors. Entries appended during
// the drain stay for the run loop: a drain under a steady writer ends.
//
// Algorithm faithful to V2 weed/storage/blockvol/flusher.go
// FlushOnce. See type doc for the full sequence and the rationale
@@ -159,15 +211,51 @@ func (f *flusher) flushOnceAllowClosed() error {
return f.flushOnceInternal(true)
}
func (f *flusher) flushOnceInternal(allowClosed bool) (err error) {
func (f *flusher) flushOnceInternal(allowClosed bool) error {
p := flushPass{limit: math.MaxUint64}
for {
r, err := f.flushCycle(allowClosed, p)
if err != nil || !r.more {
return err
}
p = r.next(r.frontier)
}
}
// boundCycleBatch keeps the LSN prefix of entries whose data fits in budget
// bytes, cut only at a record boundary: a native batch is one WAL record
// whose blocks carry consecutive LSNs (one WALOffset), and every entry of the
// last kept record stays, so a record is never split; the first record is
// kept whole even when it alone is over budget, so a cycle always makes
// progress. more reports entries left for the next cycle. It reorders
// entries by LSN.
func boundCycleBatch(entries []snapshotEntry, budget uint64, blockSize uint32) (kept []snapshotEntry, more bool) {
if uint64(len(entries))*uint64(blockSize) <= budget {
return entries, false
}
sort.Slice(entries, func(i, j int) bool { return entries[i].LSN < entries[j].LSN })
k := int(max(budget/uint64(blockSize), 1))
cut, rec := entries[k-1].LSN, entries[k-1].WALOffset
for k < len(entries) && (entries[k].LSN <= cut || entries[k].WALOffset == rec) {
cut = max(cut, entries[k].LSN)
k++
}
return entries[:k], k < len(entries)
}
// flushCycle runs one bounded cycle over the entries of pass p: LSN above
// p.after (within its recovery lifetime) and at or below both the synced WAL
// frontier and p.limit.
func (f *flusher) flushCycle(allowClosed bool, p flushPass) (r flushCycleResult, err error) {
defer f.instr.endBusyPhase()
cycleStart := time.Now()
store := f.store
if err := store.stickyIOFault(); err != nil {
return err // no checkpoint advance after a failed fsync
return r, err // no checkpoint advance after a failed fsync
}
if err := store.syncWALPressureV3(); err != nil {
return fmt.Errorf("flusher: pressure WAL sync: %w", err)
return r, fmt.Errorf("flusher: pressure WAL sync: %w", err)
}
if f.beforeSnapshotForTest != nil {
@@ -176,7 +264,7 @@ func (f *flusher) flushOnceInternal(allowClosed bool) (err error) {
store.mu.RLock()
if store.closed && !allowClosed {
store.mu.RUnlock()
return nil
return r, nil
}
// A store opened for chunk use drains nothing before its chunk layer
// attaches: the dirty blocks stay in the WAL (replayed again after a
@@ -187,7 +275,8 @@ func (f *flusher) flushOnceInternal(allowClosed bool) (err error) {
// started before the hold and snapshots the recovered dirty map sees it.
if store.drainHeld.Load() {
store.mu.RUnlock()
return nil
f.instr.setPhase(flusherDrainHeld)
return r, nil
}
snapshotStart := time.Now()
// Hold the publication lock across all shards: a later shard must not
@@ -198,6 +287,11 @@ func (f *flusher) flushOnceInternal(allowClosed bool) (err error) {
var recoveryGen uint64
recoveryGen = store.v3.recoverGen.Load()
r.gen = recoveryGen
after := p.after
if p.gen != recoveryGen {
after = 0 // another recovery lifetime: LSNs may be reused, start the pass over
}
entries := store.dm.snapshot()
// Write-ahead (INV-WAL-V3-WRITE-AHEAD-001): only entries whose WAL
@@ -208,18 +302,37 @@ func (f *flusher) flushOnceInternal(allowClosed bool) (err error) {
// synced entry is idle: no extent write and no fsync.
synced := store.v3.wack.Load()
store.mu.RUnlock()
r.frontier = min(synced, p.limit)
dirty := len(entries)
kept := entries[:0]
for _, e := range entries {
if e.LSN <= synced {
if e.LSN > after && e.LSN <= r.frontier {
kept = append(kept, e)
}
}
entries = kept
if len(entries) == 0 {
return store.refreshW() // the mode-C idle refresh (DESIGN 6.2)
if dirty > 0 && after == 0 && p.limit == math.MaxUint64 {
f.instr.setPhase(flusherWALSync) // every dirty entry is above the synced frontier
} else {
f.instr.setPhase(flusherIdle)
}
return r, store.refreshW() // the mode-C idle refresh (DESIGN 6.2)
}
desc, floorBefore, floorOK := store.v3.pub.walSnapshotV3()
walSize := desc.WALSize
if walSize == 0 {
walSize = store.sb.WALSize
}
entries, r.more = boundCycleBatch(entries, walSize/16, store.sb.BlockSize)
if r.more {
f.instr.boundedCycles.Add(1)
}
for _, e := range entries {
r.last = max(r.last, e.LSN)
}
f.instr.setPhase(flusherWriting)
if f.afterSnapshotForTest != nil {
f.afterSnapshotForTest()
}
@@ -251,7 +364,10 @@ func (f *flusher) flushOnceInternal(allowClosed bool) (err error) {
for _, e := range entries {
data, _, err := f.readDirtyRecordV3Cached(e, recordCache)
if err != nil {
return err
return r, err
}
if f.beforeExtentWriteForTest != nil {
f.beforeExtentWriteForTest()
}
writeStart := time.Now()
written, err := store.writeExtentIfCurrent(e.LBA, e.LSN, data)
@@ -259,7 +375,7 @@ func (f *flusher) flushOnceInternal(allowClosed bool) (err error) {
f.instr.recordExtentWrite(len(data), time.Since(writeStart), err)
}
if err != nil {
return fmt.Errorf("flusher: write extent LBA %d: %w", e.LBA, err)
return r, fmt.Errorf("flusher: write extent LBA %d: %w", e.LBA, err)
}
if written {
f.bytesOut.Add(uint64(len(data)))
@@ -273,11 +389,12 @@ func (f *flusher) flushOnceInternal(allowClosed bool) (err error) {
}
// Step 2: one fsync covers all extent writes in this batch
// (and any other in-flight WAL writes since they share a file).
f.instr.setPhase(flusherExtentSync)
syncStart := time.Now()
syncErr := store.syncFile(nil, func() error { return store.syncExtentFile() })
f.instr.recordExtentSync(time.Since(syncStart), syncErr)
if syncErr != nil {
return fmt.Errorf("flusher: fsync after extent writes: %w", syncErr)
return r, fmt.Errorf("flusher: fsync after extent writes: %w", syncErr)
}
if f.afterExtentSyncForTest != nil {
@@ -293,13 +410,17 @@ func (f *flusher) flushOnceInternal(allowClosed bool) (err error) {
// The released tail is persisted with the checkpoint, before the
// writer may reuse those bytes.
var publishErr error
f.instr.setPhase(flusherCheckpoint)
cpBefore := store.CheckpointLSN()
publishErr = store.persistCheckpointV3(maxLSN, recoveryGen)
f.instr.recordCheckpoint(publishErr, cpBefore, store.CheckpointLSN(), time.Now())
if _, floorAfter, ok := store.v3.pub.walSnapshotV3(); ok && floorOK && floorAfter > floorBefore {
f.instr.reclaimedBytes.Add(floorAfter - floorBefore)
}
if err := publishErr; err != nil {
return fmt.Errorf("flusher: persist checkpoint %d: %w", maxLSN, err)
return r, fmt.Errorf("flusher: persist checkpoint %d: %w", maxLSN, err)
}
}
@@ -321,7 +442,7 @@ func (f *flusher) flushOnceInternal(allowClosed bool) (err error) {
store.mu.Lock()
if !store.v3.flushLifetimeValidV3(recoveryGen) {
store.mu.Unlock()
return mapCoverageRefusal("recovery_lifetime_changed")
return r, mapCoverageRefusal("recovery_lifetime_changed")
}
checkpoint := store.checkpointLSN
if checkpoint >= maxLSN && maxLSN+1 > store.walTail {
@@ -339,7 +460,7 @@ func (f *flusher) flushOnceInternal(allowClosed bool) (err error) {
f.flushes.Add(1)
return store.refreshW() // the mode-C idle refresh (DESIGN 6.2)
return r, store.refreshW() // the mode-C idle refresh (DESIGN 6.2)
}
@@ -65,7 +65,26 @@ type FlusherInstrumentationStatus struct {
CheckpointMetadataSyncNanos uint64
}
// The flusher's phase: what it is doing, or what it waits on.
const (
flusherIdle int32 = iota // nothing to drain
flusherDrainHeld // a chunk-opened store drains nothing before its chunk layer attaches
flusherWALSync // every dirty entry is above the synced WAL frontier
flusherWriting // writing a cycle's entries to the extent
flusherExtentSync // the cycle's extent fsync
flusherCheckpoint // persisting the cycle's checkpoint
)
var flusherPhaseNames = [...]string{"idle", "drain_held", "wal_sync", "writing", "extent_sync", "checkpoint"}
type flusherInstrumentation struct {
phase atomic.Int32
reclaimedBytes atomic.Uint64 // WAL bytes released by checkpoint advances (the reuse floor's moves)
boundedCycles atomic.Uint64 // cycles that left entries at or below the frontier for the next
cycleStartNanos atomic.Int64 // the cycle in progress (0: none)
cycleExtentBytes atomic.Uint64 // extent bytes the cycle in progress wrote
lastExtentWriteNanos atomic.Int64
checkpointSuccesses atomic.Uint64
checkpointRefusals atomic.Uint64
checkpointFailures atomic.Uint64
@@ -128,6 +147,8 @@ func (i *flusherInstrumentation) recordCycle(
blockSize uint32,
) func(bool) {
i.cyclesStarted.Add(1)
i.cycleExtentBytes.Store(0)
i.cycleStartNanos.Store(cycleStart.UnixNano())
i.snapshotEntries.Add(uint64(len(entries)))
i.snapshotDurationNanos.Add(storageDurationNanos(snapshotDuration))
opportunityStart := time.Now()
@@ -139,6 +160,7 @@ func (i *flusherInstrumentation) recordCycle(
i.snapshotCoalescibleEntries.Add(opportunity.coalescibleEntries)
updateAtomicMax(&i.snapshotMaxContiguousRunBlocks, opportunity.maxRun)
return func(success bool) {
i.cycleStartNanos.Store(0)
duration := storageDurationNanos(time.Since(cycleStart))
i.cycleDurationNanos.Add(duration)
updateAtomicMax(&i.cycleMaxDurationNanos, duration)
@@ -253,6 +275,27 @@ func (i *flusherInstrumentation) recordExtentWrite(bytes int, duration time.Dura
return
}
i.extentWriteBytes.Add(value)
i.cycleExtentBytes.Add(value)
i.lastExtentWriteNanos.Store(time.Now().UnixNano())
}
func (i *flusherInstrumentation) setPhase(p int32) { i.phase.Store(p) }
// endBusyPhase returns a cycle's busy phase to idle when the cycle ends; the
// waiting phases (drain held, WAL sync) stay until the next cycle.
func (i *flusherInstrumentation) endBusyPhase() {
for _, p := range []int32{flusherWriting, flusherExtentSync, flusherCheckpoint} {
if i.phase.CompareAndSwap(p, flusherIdle) {
return
}
}
}
func (i *flusherInstrumentation) phaseName() string {
if p := i.phase.Load(); p >= 0 && int(p) < len(flusherPhaseNames) {
return flusherPhaseNames[p]
}
return "unknown"
}
func (i *flusherInstrumentation) recordExtentSync(duration time.Duration, err error) {
@@ -35,7 +35,7 @@ var walStoreMethods = map[string]string{
"Coverage": "read (atomic local bitmap coverage and chunk position)",
"AllBlocks": "read", "AppliedLSNs": "read", "CanSeedChunkFrontier": "read (the seed precondition, no write)", "BlockSize": "read", "StoreID": "read (the superblock UUID)", "ChunkBlocks": "read (immutable local map shape)", "ChunkStateMarker": "read (the descriptor's chunk-state marker)", "Boundaries": "read", "CheckpointLSN": "read",
"CheckpointLSNForPOC": "read", "CheckpointPersistence": "read", "ChunkMapStatsV3": "read", "DataSyncPolicy": "read",
"DurabilityLatency": "read", "ExtentDrainHeld": "read", "FlushCount": "read", "FlusherInstrumentation": "read", "HolesSuspected": "read",
"DurabilityLatency": "read", "ExtentDrainHeld": "read", "FlushCount": "read", "FlusherInstrumentation": "read", "HolesSuspected": "read", "ReclaimProgress": "read",
"InstalledBaseLSN": "read", "LayoutIdentity": "read", "NextLSN": "read", "NumBlocks": "read",
"OwnerChunkAttachDurableV3": "read", "Read": "read", "ReadContext": "read", "RecoveryMode": "read",
"RecoveryRetentionLSNs": "read", "RecoveryWarnings": "read", "ScanLBAs": "read", "WALCapacityBytes": "read",
@@ -0,0 +1,320 @@
package storage
import (
"bytes"
"errors"
"math"
"math/rand"
"path/filepath"
"testing"
"time"
)
// A batch is an LSN prefix cut only at a record boundary: a native batch (one
// WAL record, consecutive LSNs) is never split, the first record is kept
// whole even over budget, and more reports what is left.
func TestBoundCycleBatchCutsOnlyAtARecordBoundary(t *testing.T) {
es := func(lsns ...uint64) []snapshotEntry {
out := make([]snapshotEntry, len(lsns))
for i, l := range lsns {
out[i] = snapshotEntry{LBA: uint64(i), LSN: l, WALOffset: 4096 * l}
}
return out
}
batch := func(es []snapshotEntry, from, to uint64) []snapshotEntry { // LSNs from..to share one record
for i := range es {
if es[i].LSN >= from && es[i].LSN <= to {
es[i].WALOffset = 4096 * from
}
}
return es
}
lsns := func(es []snapshotEntry) []uint64 {
out := make([]uint64, len(es))
for i, e := range es {
out[i] = e.LSN
}
return out
}
for _, tc := range []struct {
name string
in []snapshotEntry
blocks uint64 // the budget in blocks
want []uint64
more bool
}{
{"fits", es(3, 1, 2), 3, []uint64{3, 1, 2}, false},
{"prefix by LSN, not by order", es(9, 1, 5, 2, 7), 2, []uint64{1, 2}, true},
{"a multi-block record stays whole", es(4, 2, 2, 2, 1), 2, []uint64{1, 2, 2, 2}, true},
{"a native batch (consecutive LSNs, one record) stays whole", batch(es(1, 2, 3, 4, 5), 1, 3), 2, []uint64{1, 2, 3}, true},
{"the first LSN over budget is kept whole", es(6, 6, 6, 8), 1, []uint64{6, 6, 6}, true},
{"the tail is one record", es(1, 2, 2), 2, []uint64{1, 2, 2}, false},
} {
t.Run(tc.name, func(t *testing.T) {
got, more := boundCycleBatch(tc.in, tc.blocks*4096, 4096)
if g := lsns(got); more != tc.more || len(g) != len(tc.want) {
t.Fatalf("got %v more=%v, want %v more=%v", g, more, tc.want, tc.more)
}
for i, l := range lsns(got) {
if l != tc.want[i] {
t.Fatalf("got %v, want %v", lsns(got), tc.want)
}
}
})
}
}
// One bounded cycle checkpoints at the batch's last LSN L while a newer
// record of an LBA whose older record is at or below L is still unflushed: a
// crash then replays the newer record, and every LBA of the batch reads back
// from the extent.
func TestWALStoreV3BoundedCheckpointReplaysANewerRecordAfterACrash(t *testing.T) {
const walSize = 256 * 1024 // a batch of 16 KiB: 4 blocks
path := filepath.Join(t.TempDir(), "volume")
s, err := createMappedWALStoreV3ForTest(path, 64, 4096, walSize, WModeLagged, 4)
if err != nil {
t.Fatal(err)
}
s.DisableAutoFlushForRecoveryTest()
// LSN 1: LBA 0 = A; LSNs 2..8: LBAs 1..7; LSN 9: LBA 0 = B.
if _, err := s.Write(0, blk(0xA)); err != nil {
t.Fatal(err)
}
for i := uint32(1); i <= 7; i++ {
if _, err := s.Write(i, blk(byte(i))); err != nil {
t.Fatal(err)
}
}
newest, err := s.Write(0, blk(0xB))
if err != nil {
t.Fatal(err)
}
if _, err := s.Sync(); err != nil {
t.Fatal(err)
}
r, err := s.flusher.flushCycle(false, flushPass{limit: math.MaxUint64})
if err != nil {
t.Fatal(err)
}
cp := s.CheckpointLSN()
if !r.more || cp == 0 || cp >= newest {
t.Fatalf("one bounded cycle: more=%v checkpoint=%d, want entries left and a checkpoint below LBA 0's newer record %d", r.more, cp, newest)
}
if st := s.CheckpointPersistence(); st.BoundedCycles != 1 || st.ReclaimedBytes == 0 {
t.Fatalf("counters after one bounded cycle: %+v", st)
}
crashRecoveryHardeningStore(t, s)
re, err := openWALStoreV3ForTest(path)
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = re.Close() })
re.DisableAutoFlushForRecoveryTest()
if _, err := re.Recover(); err != nil {
t.Fatal(err)
}
if got := re.CheckpointLSN(); got != cp {
t.Fatalf("recovered checkpoint %d, want %d", got, cp)
}
if got, err := re.Read(0); err != nil || !bytes.Equal(got, blk(0xB)) {
t.Fatalf("LBA 0 after the crash: err=%v, want the newer record's data (B)", err)
}
for i := uint32(1); i <= 7; i++ {
if got, err := re.Read(i); err != nil || !bytes.Equal(got, blk(byte(i))) {
t.Fatalf("LBA %d after the crash: err=%v", i, err)
}
}
}
// A full drain (flushOnce) still drains every synced entry, in bounded
// cycles, however many batches they span.
func TestWALStoreV3FullDrainRunsBoundedCyclesToTheEnd(t *testing.T) {
const walSize = 256 * 1024
path := filepath.Join(t.TempDir(), "volume")
s, err := createMappedWALStoreV3ForTest(path, 64, 4096, walSize, WModeLagged, 4)
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = s.Close() })
s.DisableAutoFlushForRecoveryTest()
var last uint64
for i := uint32(0); i < 40; i++ {
if last, err = s.Write(i, blk(byte(i+1))); err != nil {
t.Fatal(err)
}
}
if _, err := s.Sync(); err != nil {
t.Fatal(err)
}
if err := s.flusher.flushOnce(); err != nil {
t.Fatal(err)
}
st := s.CheckpointPersistence()
if st.CheckpointLSN != last || st.BoundedCycles < 9 || s.dm.len() != 0 || st.FlusherPhase != "idle" {
t.Fatalf("after a full drain of 40 blocks in 4-block batches: %+v dirty=%d, want checkpoint %d, at least 9 bounded cycles, none dirty, idle", st, s.dm.len(), last)
}
}
// A chunk-opened store drains nothing before its chunk layer attaches, and
// the flusher's phase says so (not idle, not a stall in a cycle).
func TestWALStoreV3DrainHeldIsTheFlusherPhase(t *testing.T) {
path := filepath.Join(t.TempDir(), "volume")
s, err := createMappedWALStoreV3ForTest(path, 64, 4096, 256*1024, WModeLagged, 4)
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = s.Close() })
s.DisableAutoFlushForRecoveryTest()
s.HoldExtentDrainUntilChunkLayer()
if _, err := s.Write(3, blk(3)); err != nil {
t.Fatal(err)
}
if _, err := s.Sync(); err != nil {
t.Fatal(err)
}
if err := s.flusher.flushOnce(); err != nil {
t.Fatal(err)
}
if st := s.CheckpointPersistence(); st.FlusherPhase != "drain_held" || st.CheckpointLSN != 0 || st.ReclaimedBytes != 0 {
t.Fatalf("a held drain: %+v, want phase drain_held and nothing reclaimed", st)
}
}
// A dense image written as single 4 KiB writes in random order, three
// WALs' worth, on a slow disk (every extent write takes 2 ms), with a 500 ms admission
// budget. A whole-map cycle (about 480 entries, about 1 s) frees nothing
// until it ends, so a write times out waiting for space; bounded cycles free
// space every sixteenth of the WAL, and no write times out while reclaim
// moves. The guest sees a slow disk, not errors.
func TestWALStoreV3SlowExtentKeepsReclaimMoving(t *testing.T) {
const walSize = 2 << 20
const count = 3 * walSize / 4096
path := filepath.Join(t.TempDir(), "volume")
s, err := createMappedWALStoreV3ForTest(path, count, 4096, walSize, WModeLagged, 64)
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = s.Close() })
s.admissionTimeout = 500 * time.Millisecond
s.flusher.beforeExtentWriteForTest = func() { time.Sleep(2 * time.Millisecond) }
lbas := rand.New(rand.NewSource(1)).Perm(count)
start := time.Now()
busy := 0
var maxAttempt time.Duration
for n, lba := range lbas {
for {
a := time.Now()
_, err := s.Write(uint32(lba), blk(byte(lba+1)))
maxAttempt = max(maxAttempt, time.Since(a))
if err == nil {
break
}
if !errors.Is(err, ErrWALPressureTimeout) || time.Since(start) > 2*time.Minute {
t.Fatalf("write %d lba=%d: %v", n, lba, err)
}
busy++
t.Logf("busy write=%d lba=%d at %v: %+v", n, lba, time.Since(start), s.CheckpointPersistence())
}
}
st := s.CheckpointPersistence()
t.Logf("writes=%d busy=%d maxAttempt=%v total=%v %+v", count, busy, maxAttempt, time.Since(start), st)
if busy != 0 {
t.Fatalf("%d writes timed out waiting for WAL space while reclaim moved (max attempt %v)", busy, maxAttempt)
}
if st.BoundedCycles == 0 || st.ReclaimedBytes < walSize {
t.Fatalf("reclaim counters: %+v", st)
}
for _, lba := range lbas {
if got, err := s.Read(uint32(lba)); err != nil || !bytes.Equal(got, blk(byte(lba+1))) {
t.Fatalf("readback %d: %v", lba, err)
}
}
}
// ReclaimProgress answers while the store lock is held (a write's hold path
// reads it without waiting behind a cycle or a publication), and moves with
// a drain.
func TestWALStoreV3ReclaimProgressReadsNoStoreLock(t *testing.T) {
path := filepath.Join(t.TempDir(), "volume")
s, err := createMappedWALStoreV3ForTest(path, 64, 4096, 256*1024, WModeLagged, 4)
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = s.Close() })
s.DisableAutoFlushForRecoveryTest()
for i := uint32(0); i < 8; i++ {
if _, err := s.Write(i, blk(byte(i+1))); err != nil {
t.Fatal(err)
}
}
if _, err := s.Sync(); err != nil {
t.Fatal(err)
}
before := s.ReclaimProgress()
if err := s.flusher.flushOnce(); err != nil {
t.Fatal(err)
}
s.mu.Lock()
got := make(chan ReclaimProgress, 1)
go func() { got <- s.ReclaimProgress() }()
var after ReclaimProgress
select {
case after = <-got:
case <-time.After(2 * time.Second):
s.mu.Unlock()
t.Fatal("ReclaimProgress waited for the store lock")
}
s.mu.Unlock()
if after.ReclaimedBytes <= before.ReclaimedBytes || after.ExtentBytes < before.ExtentBytes+8*4096 || after.Advances < 2 || after.Phase != "idle" {
t.Fatalf("progress across a drain of 8 blocks in 4-block batches: before %+v after %+v", before, after)
}
}
// A checkpoint held below the batch (here by an active recycle floor) does
// not make a drain repeat the same batch: the pass moves past it, writes
// every entry to the extent once (as a whole-map cycle did) and ends, with
// the checkpoint at the floor. A Recover starts the pass over.
func TestWALStoreV3HeldCheckpointEndsTheDrain(t *testing.T) {
path := filepath.Join(t.TempDir(), "volume")
s, err := createMappedWALStoreV3ForTest(path, 64, 4096, 256*1024, WModeLagged, 4)
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = s.Close() })
s.DisableAutoFlushForRecoveryTest()
for i := uint32(0); i < 12; i++ {
if _, err := s.Write(i, blk(byte(i+1))); err != nil {
t.Fatal(err)
}
}
if _, err := s.Sync(); err != nil {
t.Fatal(err)
}
s.SetRecycleFloorSource(&fakeRecycleFloorSource{floor: 6, anyActive: true})
done := make(chan error, 1)
go func() { done <- s.flusher.flushOnce() }()
select {
case err := <-done:
if err != nil {
t.Fatal(err)
}
case <-time.After(10 * time.Second):
t.Fatal("a drain held by the recycle floor did not end")
}
if cp := s.CheckpointLSN(); cp != 6 {
t.Fatalf("checkpoint=%d, want the floor 6", cp)
}
for i := uint32(0); i < 12; i++ {
if got, err := s.readFromExtent(i); err != nil || !bytes.Equal(got, blk(byte(i+1))) {
t.Fatalf("LBA %d not in the extent after a held drain: %v", i, err)
}
if got, err := s.Read(i); err != nil || !bytes.Equal(got, blk(byte(i+1))) {
t.Fatalf("LBA %d: %v", i, err)
}
}
// A pass position from another recovery lifetime is not trusted.
r, err := s.flusher.flushCycle(false, flushPass{after: 11, gen: s.v3.recoverGen.Load() + 1, limit: math.MaxUint64})
if err != nil || r.last == 0 || r.last > 11 { // a trusted stale position would take only LSN 12
t.Fatalf("a stale pass position: last=%d err=%v, want the pass to restart at the oldest dirty entry", r.last, err)
}
}
+2 -1
View File
@@ -83,7 +83,7 @@ stateDiagram-v2
| 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` |
| Serving | Serving (checkpoint) | the flusher binds its snapshot/materialization to one recovery lifetime; extent and owned COW map are durable before the shared descriptor publisher advances checkpoint/tail; both slot tails pin reuse | `core/storage/flusher.go` `flushOnceInternal`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `INV-WAL-CHECKPOINT-SNAPSHOT-001`, `INV-WAL-REUSE-PERSISTED-TAIL-001`, `INV-WAL-CKPT-META-FAIL-001`, `INV-CUT-BITMAP-001`, `INV-WAL-FLUSH-SYNC-COVERS-WAL-001`, `INV-WAL-V3-RECLAIM-001`, `INV-WAL-V3-PUBLISH-NONCE-FLOOR-001`, `INV-WAL-V3-MAP-PRIOR-LIVE-001` |
| Serving | Serving (checkpoint) | the flusher binds its snapshot/materialization to one recovery lifetime; extent and owned COW map are durable before the shared descriptor publisher advances checkpoint/tail; both slot tails pin reuse | `core/storage/flusher.go` `flushOnceInternal`, `flushCycle`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `INV-WAL-CHECKPOINT-SNAPSHOT-001`, `INV-WAL-CHECKPOINT-PREFIX-001`, `INV-WAL-REUSE-PERSISTED-TAIL-001`, `INV-WAL-CKPT-META-FAIL-001`, `INV-CUT-BITMAP-001`, `INV-WAL-FLUSH-SYNC-COVERS-WAL-001`, `INV-WAL-V3-RECLAIM-001`, `INV-WAL-V3-PUBLISH-NONCE-FLOOR-001`, `INV-WAL-V3-MAP-PRIOR-LIVE-001` |
| Serving | Serving (map prepare refused) | a map preparer (the flusher's checkpoint, the chunk layer's captured-map publication, BASE complete) captured prior and a publication released it before the prepare's live-set snapshot: the prepare reuses no page, writes nothing, refuses with `prior_released` without latching, counts it, and the caller's next cycle prepares from the current root | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3`; `core/storage/chunk_map_extents_v3.go` `liveSnapshotWithPriorV3`; `core/storage/map_extent_pins.go` `reserveCoverageV3` | `INV-WAL-V3-MAP-PRIOR-LIVE-001` |
| Serving | FaultLatched | the first failed `fsync` of the store file, or a WAL append whose write failed | `core/storage/walstore.go` `noteFsyncFailure`, `syncFile`; `core/storage/walstore_v3.go` `appendWriteV3` | `INV-WAL-FSYNC-STICKY-001`, `INV-WAL-APPEND-STICKY-001` |
| FaultLatched | FaultLatched | every later `Sync`, write, checkpoint and `Recover` on the same open store is refused | `core/storage/walstore.go` `stickyIOFault` | `INV-WAL-FSYNC-STICKY-001` |
@@ -623,6 +623,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w
| `INV-WAL-REPLAY-LWW-001` | Replay of the validated native prefix retains the highest admitted LSN per LBA; invalid cursor, nonce or LSN order is refused. | M1 Recovering | `core/storage/dirty_map.go` `putAtIfNewer` | `TestWALLSNOrderV3_RefusesDuplicateAndLower` (`core/storage/wal_lsn_order_v3_test.go`) | `WALRecovery` `ReplayLastWriter` | ACTIVE |
| `INV-WAL-REUSE-PERSISTED-TAIL-001` | The WAL writer reuses only bytes that the both durable descriptor slots has already released. | M1 write lifecycle: Checkpointed → Reusable | `core/storage/wal_io_v3.go` `append`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `TestWALIOV3_FloorAndPwriteFailureRefuse` (`core/storage/wal_io_v3_test.go`); `TestNativeReplacementCallerPublicationFaults` (`core/storage/legacy_replacement_v3_test.go`) | `WALRecovery` `I1` | ACTIVE |
| `INV-WAL-CHECKPOINT-SNAPSHOT-001` | A checkpoint never passes a synced write that is not yet in the extent. | M1 write lifecycle: InExtent → Checkpointed | `core/storage/flusher.go` `flushOnceInternal` | `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` (`core/storage/walstore_map_recovery_lifetime_v3_test.go`); `TestNativeReplacementCheckpointSIGKILL` (`core/storage/legacy_checkpoint_replacement_v3_linux_test.go`) | `WALRecovery` `I1` | ACTIVE |
| `INV-WAL-CHECKPOINT-PREFIX-001` | A flusher cycle drains an LSN prefix of the synced dirty entries, at most a sixteenth of the WAL, cut only at a record boundary (a native batch, one WAL record whose blocks carry consecutive LSNs, stays whole; the first record whole even when larger), and checkpoints at its last LSN L: every record with LSN <= L is in the extent or superseded by a record of the same LBA with LSN > L, still in the WAL. The run loop starts the next cycle at once while entries remain; a full drain (`flushOnce`, the final flush of a stop) runs cycles until its first frontier is drained. A pass writes every dirty entry once even when the checkpoint is held below them (a recycle floor, retention, a map): the next cycle starts after the previous batch's last LSN, within one recovery lifetime (another lifetime restarts the pass), so a held batch is not repeated; when the hold ends the checkpoint moves over entries already written and fsynced in the pass. | M1 write lifecycle: InExtent → Checkpointed | `core/storage/flusher.go` `flushCycle`, `boundCycleBatch`, `flushOnceInternal`, `cycle`, `flushPass` | `TestBoundCycleBatchCutsOnlyAtARecordBoundary`, `TestWALStoreV3BoundedCheckpointReplaysANewerRecordAfterACrash`, `TestWALStoreV3FullDrainRunsBoundedCyclesToTheEnd`, `TestWALStoreV3SlowExtentKeepsReclaimMoving`, `TestWALStoreV3HeldCheckpointEndsTheDrain` (`core/storage/walstore_bounded_flush_v3_test.go`) | FlushCkpt CkptMeaning, ReadsLatest | ACTIVE |
| `INV-WAL-FRONTIER-GAP-001` | A durable BASE anchor and its contiguous synced install-lane suffix survive recovery; an unpersisted frontier jump is not admitted. | M1 Recovering | `core/storage/walstore_v3.go` `recoverV3` | `TestBaseInstallV3CompleteServesTheImageAcrossACrash` (`core/storage/base_install_v3_test.go`) | `WALRecovery` `I1` | ACTIVE |
| `INV-WAL-CKPT-META-FAIL-001` | A failed checkpoint metadata write neither publishes the new checkpoint nor releases WAL space. | M1 write lifecycle: InExtent → Checkpointed (refused) | `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `TestNativeReplacementCallerPublicationFaults` (`core/storage/legacy_replacement_v3_test.go`) | — | ACTIVE |
| `INV-WAL-FSYNC-STICKY-001` | After the first failed `fsync` of the store file (WAL, extent, superblock, or the chunk layer's presence save), the open store refuses every later `Sync`, write, checkpoint and presence save without calling `fsync` again; only a reopen and `Recover` clear it. | M1 Serving → FaultLatched | `core/storage/walstore.go` `noteFsyncFailure`, `syncFile`, `stickyIOFault` | `TestNativeReplacementDataFsyncFailureIsSticky` (`core/storage/legacy_replacement_v3_test.go`); `TestNativeReplacementCallerPublicationFaults` (`core/storage/legacy_replacement_v3_test.go`); `TestWALStoreV3SyncRechecksTheFaultAtTheAckBoundary` (`core/storage/walstore_v3_test.go`); `TestAPresenceSaveIsRefusedAfterAFailedFsync`, `TestAPresenceSavesFailedFsyncStaysFailed` (`core/storage/chunk_presence_fsync_test.go`) | — | ACTIVE |
+5
View File
@@ -24,6 +24,11 @@ These notes collect v1.1's changes as they land; v1.1 is not released.
the cgroup2 mount visible in its mount namespace) now starts on the 256 MiB default soft limit and logs one
`level=WARN` line naming why, instead of exiting 2; status reports the reason in `Memory.SoftLimitFallback`. An
explicit but invalid `--memory-limit-mib` or `GOMEMLIMIT` still refuses.
- The WAL flusher reclaims in bounded steps: each cycle flushes the oldest synced writes up to a sixteenth of the WAL
and advances the checkpoint, instead of flushing every dirty block before freeing any WAL space. On a slow disk a
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`.
## Upgrade
- With `--host-limit-dir` set, the limiter's `configuration.json` in that directory records the flags it was
+6
View File
@@ -213,6 +213,12 @@ Durable store state of the served volume. Go type `volume.durableStatusBody`.
| `Volumes[].CheckpointPersistence.CheckpointLSN` | uint64 | the persisted checkpoint LSN |
| `Volumes[].CheckpointPersistence.Advances` | uint64 | successes that moved CheckpointLSN forward |
| `Volumes[].CheckpointPersistence.LastAdvance` | time (RFC 3339) | when the latest advance happened; zero if none in this open |
| `Volumes[].CheckpointPersistence.ReclaimedBytes` | uint64 | WAL bytes the checkpoint advances released in this open |
| `Volumes[].CheckpointPersistence.BoundedCycles` | uint64 | flusher cycles that stopped at the batch bound (a sixteenth of the WAL) with entries left for the next |
| `Volumes[].CheckpointPersistence.FlusherPhase` | string | idle, drain_held (before the chunk layer attaches), wal_sync (every dirty entry above the synced WAL), writing, extent_sync or checkpoint |
| `Volumes[].CheckpointPersistence.CycleStarted` | time (RFC 3339) | when the flusher cycle in progress started; zero when none is |
| `Volumes[].CheckpointPersistence.CycleExtentBytes` | uint64 | extent bytes the cycle in progress (or the latest) has written |
| `Volumes[].CheckpointPersistence.LastExtentWrite` | time (RFC 3339) | when the flusher last wrote extent bytes; zero if never in this open |
| `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 |