From 3b3a154121aa45944b10fef0825dcc615fdada9c Mon Sep 17 00:00:00 2001 From: pingqiu Date: Tue, 1 Dec 2026 16:46:04 -0800 Subject: [PATCH] durable: test, the no-flush passive wait follows the flusher's cycle The passive check after the first busy write gave the checkpoint a fixed 10 s. A flusher cycle on a slow or loaded disk can take longer: with a cycle slowed to 14 s the test fails exactly as on CI (bytes=60424192, cp=0, busy=1), and at 5 s the checkpoint advances 1.8 s into the wait with no further write. The 10 s window now counts from the last moment a flusher cycle was in progress (FlusherInstrumentation), up to the write's retry deadline; a completed cycle that did not advance the checkpoint does not extend it. The log and the failure print the flusher's cycle counts, so a next failure tells a slow cycle from none. Co-Authored-By: Claude Opus 5.5 --- .../durable/provider_chunk_noflush_test.go | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/seaweed-block/core/frontend/durable/provider_chunk_noflush_test.go b/seaweed-block/core/frontend/durable/provider_chunk_noflush_test.go index f4dec3dd68..e03fca3605 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk_noflush_test.go +++ b/seaweed-block/core/frontend/durable/provider_chunk_noflush_test.go @@ -125,14 +125,30 @@ func runNoClientFlushBurst(t *testing.T, mode storage.WMode) { target := ws.NextLSN() - 1 cpObserved := cpAtBusy // Getters only: no Write, Sync, NotifyUrgent or Close may - // drive progress before the first retry. - for cpAtBusy < target && cpObserved <= cpAtBusy && time.Since(passiveStart) < 10*time.Second { + // drive progress before the first retry. The 10 s window + // counts from the last moment a flusher cycle was in + // progress: a cycle slower than the window (a slow disk on a + // loaded host) is waited for, up to the write's retry + // deadline. A completed cycle that did not advance the + // checkpoint does not extend it, so a flusher that cycles + // without reclaiming still fails within the window. + const passiveWindow = 10 * time.Second + lastInCycle := passiveStart + flushing := func() bool { + fi := ws.FlusherInstrumentation() + return fi.CyclesStarted > fi.CyclesSucceeded+fi.CyclesFailed + } + for cpAtBusy < target && cpObserved <= cpAtBusy && time.Since(lastInCycle) < passiveWindow && time.Now().Before(retryDeadline) { time.Sleep(25 * time.Millisecond) cpObserved = ws.CheckpointLSN() + if flushing() { + lastInCycle = time.Now() + } } - t.Logf("NO FLUSH passive bytes=%d wait=%v cpBefore=%d cpAtBusy=%d cpObserved=%d target=%d", off, time.Since(passiveStart), cpBefore, cpAtBusy, cpObserved, target) - if time.Since(passiveStart) >= 10*time.Second || (cpAtBusy < target && cpObserved <= cpAtBusy) { - t.Fatalf("NO FLUSH passive checkpoint did not advance without another write: bytes=%d cp=%d busy=%d", off, cpObserved, busyCount) + fi := ws.FlusherInstrumentation() + t.Logf("NO FLUSH passive bytes=%d wait=%v cpBefore=%d cpAtBusy=%d cpObserved=%d target=%d flusher: cycles started=%d succeeded=%d failed=%d max=%v, last in a cycle %v ago", off, time.Since(passiveStart), cpBefore, cpAtBusy, cpObserved, target, fi.CyclesStarted, fi.CyclesSucceeded, fi.CyclesFailed, time.Duration(fi.CycleMaxDurationNanos), time.Since(lastInCycle)) + if cpAtBusy < target && cpObserved <= cpAtBusy { + t.Fatalf("NO FLUSH passive checkpoint did not advance without another write: bytes=%d cp=%d busy=%d (flusher in a cycle %v ago, cycles started=%d succeeded=%d failed=%d)", off, cpObserved, busyCount, time.Since(lastInCycle), fi.CyclesStarted, fi.CyclesSucceeded, fi.CyclesFailed) } } // Retry the identical command; no caller Flush drives reclamation.