From d5de79f75ba4fc6c285cf53c54a9d055faea50ad Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Sun, 6 Sep 2026 19:00:10 +0800 Subject: [PATCH] =?UTF-8?q?test=E2=9C=85:=20join=20the=20producer=20before?= =?UTF-8?q?=20the=20test=20returns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The publishing goroutine was told to stop and never waited for. t.Cleanup restores sdk.Runtime while a producer that has not yet noticed the stop is still reading it, which -race reports as a write and a read on the same package variable. Signalling is not joining. --- common/storage/queue_swap_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/storage/queue_swap_test.go b/common/storage/queue_swap_test.go index cbe44f58..6d253363 100644 --- a/common/storage/queue_swap_test.go +++ b/common/storage/queue_swap_test.go @@ -73,7 +73,12 @@ func TestAReloadNeverPointsProducersAtAClosedQueue(t *testing.T) { var refused atomic.Int64 var attempts atomic.Int64 stop := make(chan struct{}) + // publishing is closed by the producer on its way out. The test joins on it + // before returning: t.Cleanup restores sdk.Runtime, and a producer still in + // flight would be reading the variable that restore writes. + publishing := make(chan struct{}) go func() { + defer close(publishing) for { select { case <-stop: @@ -97,6 +102,7 @@ func TestAReloadNeverPointsProducersAtAClosedQueue(t *testing.T) { t.Fatal("the reload never finished") } close(stop) + <-publishing if attempts.Load() == 0 { t.Fatal("nothing was published during the reload; the test proves nothing")