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 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-05 23:52:57 -08:00
1 parent f47f3593d8
commit 3f69dcf0a0
2 files changed
+5 -22

No files matched your search

+1 -14
View File
@@ -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 {
@@ -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 {