From c21d92b70a0992643ad23344f96f1971bb800ecd Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 1 Aug 2026 20:04:40 -0700 Subject: [PATCH] test: wait for async write-budget release after pipeline shutdown (#10530) Shutdown drops the sealed-chunk map references, but an in-flight uploader goroutine holds the final reference and releases its budget slot only after reacquiring chunksLock. Asserting Used()==0 immediately after Shutdown races those releases on slow runners. Poll with a bounded deadline instead. --- weed/mount/page_writer/write_buffer_cap_integration_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/weed/mount/page_writer/write_buffer_cap_integration_test.go b/weed/mount/page_writer/write_buffer_cap_integration_test.go index 2a44f4295..175112481 100644 --- a/weed/mount/page_writer/write_buffer_cap_integration_test.go +++ b/weed/mount/page_writer/write_buffer_cap_integration_test.go @@ -160,6 +160,12 @@ func TestWriteBufferCap_SharedAcrossPipelines(t *testing.T) { if got := observedMax.Load(); got > capBytes { t.Fatalf("observed Used()=%d exceeded cap=%d", got, capBytes) } + // An uploader goroutine releases its budget slot only after reacquiring + // chunksLock post-Shutdown, so the last releases may land asynchronously. + drainDeadline := time.Now().Add(5 * time.Second) + for acc.Used() != 0 && time.Now().Before(drainDeadline) { + time.Sleep(2 * time.Millisecond) + } if got := acc.Used(); got != 0 { t.Fatalf("expected 0 used after shutdown, got %d", got) }