From 260aeffda1fb5d02a29bbee0485d6b0b7861d8a3 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 2 Dec 2026 11:52:26 -0800 Subject: [PATCH] storage: #959 gate test joins both workers before the store closes The cleanup keeps both worker handles in scope: it ends the admitted write and releases the hold, then joins the hold worker and, if started, the held extent-write worker, each bounded with a reported timeout, and closes stop only after the joins. Co-Authored-By: Claude Opus 5.5 --- .../core/storage/chunk_cut_presync_test.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/seaweed-block/core/storage/chunk_cut_presync_test.go b/seaweed-block/core/storage/chunk_cut_presync_test.go index 0055173a7a..82b23eb228 100644 --- a/seaweed-block/core/storage/chunk_cut_presync_test.go +++ b/seaweed-block/core/storage/chunk_cut_presync_test.go @@ -350,17 +350,31 @@ func TestAHoldWaitsForAnAdmittedExtentWriteAndHoldsNewOnes(t *testing.T) { held := make(chan func(), 1) go func() { held <- s.holdExtentWrites() }() var release func() - t.Cleanup(func() { // every exit: the admitted write ends, the hold is released, waiters stop + next := make(chan struct{}) // the second worker's end; nil until it starts + var nextStarted bool + // Every exit, before the store's own cleanup: the admitted write ends and + // the hold is released, then each started worker is joined (bounded, a + // timeout reported). Releasing the hold lets the second worker finish; + // stop is closed only after the joins. + t.Cleanup(func() { finish() if release == nil { select { case release = <-held: case <-time.After(ctLocalBound): + t.Error("cleanup: the hold worker did not return") } } if release != nil { release() } + if nextStarted { + select { + case <-next: + case <-time.After(ctLocalBound): + t.Error("cleanup: the held extent-write worker did not finish") + } + } close(stop) }) for deadline := time.Now().Add(ctLocalBound); ; time.Sleep(100 * time.Microsecond) { @@ -384,7 +398,7 @@ func TestAHoldWaitsForAnAdmittedExtentWriteAndHoldsNewOnes(t *testing.T) { t.Fatal("the hold did not return after the admitted write finished") } waits := s.extentHeldWaits.Load() - next := make(chan struct{}) + nextStarted = true go func() { s.admitExtentWrite(stop)(); close(next) }() for deadline := time.Now().Add(ctLocalBound); s.extentHeldWaits.Load() == waits; time.Sleep(100 * time.Microsecond) { select {