From 3f69dcf0a0184903e2cafda70178e75e17f0b6de Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 5 Dec 2026 23:52:57 -0800 Subject: [PATCH] seaweed-block: walUsedFraction reads through walPressureRLocked walPressureRLocked repeated walUsedFraction's snapshot and fill math; keep one copy, built on walSnapshotV3. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/core/storage/walstore.go | 15 +-------------- .../core/storage/write_command_budget.go | 12 ++++-------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/seaweed-block/core/storage/walstore.go b/seaweed-block/core/storage/walstore.go index 8545369fcf..320628c377 100644 --- a/seaweed-block/core/storage/walstore.go +++ b/seaweed-block/core/storage/walstore.go @@ -327,20 +327,7 @@ func openInitializedV3(path string, f *os.File, sb *superblock, metadata BlockMe func (s *WALStore) walUsedFraction() float64 { s.mu.RLock() defer s.mu.RUnlock() - - w := s.v3.w - if w == nil { - // Not a capacity decision: append must retain its typed binding refusal - // without waiting for pressure that cannot be relieved before Recover. - return 0 - } - d, floor, valid := s.v3.pub.walSnapshotV3() - w.mu.Lock() - defer w.mu.Unlock() - if !valid || d.WALSize == 0 || d.Nonce != w.nonce || w.head < floor || w.head-floor > d.WALSize { - return 0 // append's binding validation still refuses; this grants no reuse - } - return float64(w.head-floor) / float64(d.WALSize) + return s.walPressureRLocked() } func retainedLSNFromCheckpoint(checkpointLSN uint64) uint64 { diff --git a/seaweed-block/core/storage/write_command_budget.go b/seaweed-block/core/storage/write_command_budget.go index fa80de7447..58cf17562f 100644 --- a/seaweed-block/core/storage/write_command_budget.go +++ b/seaweed-block/core/storage/write_command_budget.go @@ -111,18 +111,14 @@ func (s *WALStore) writePressureSample(ctx context.Context, deadline time.Time) } // walPressureRLocked is the V3 WAL fill fraction; s.mu is read-locked. A -// missing binding or an inconsistent snapshot reads 0 (append still refuses it). +// missing binding or an inconsistent snapshot reads 0: it is not a capacity +// decision, and append's binding validation still refuses. func (s *WALStore) walPressureRLocked() float64 { - v := s.v3 - w := v.w + w := s.v3.w if w == nil { return 0 } - p := v.pub - p.descMu.Lock() - floor, valid := p.reuseFloorLocked() - d := p.cur - p.descMu.Unlock() // preserve snapshot ordering: no descriptor -> writer edge + d, floor, valid := s.v3.pub.walSnapshotV3() w.mu.Lock() defer w.mu.Unlock() if !valid || d.WALSize == 0 || d.Nonce != w.nonce || w.head < floor || w.head-floor > d.WALSize {