From 6138d2d74cdd318c84ce00b0f5c6f6786dd579d5 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Sun, 6 Sep 2026 19:00:20 +0800 Subject: [PATCH] =?UTF-8?q?test=E2=9C=85:=20assert=20the=20bound=20install?= =?UTF-8?q?ing=20first=20actually=20gives?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The assertion demanded zero refusals during a reload, and this ordering cannot deliver that. GetQueuePrefix returns a wrapper that captured the adapter, so a producer that fetched before the swap and appends after Shutdown has begun is still holding the old queue. That window is one call wide; closing it means resolving the adapter inside Append, which is core's to change. What the ordering removes is the sustained window - every producer that fetches during the wait. Measured on a race-enabled run: 174 of 174 publishes refused with the old order, 1 of 174 with the new one. The old assertion therefore failed about half the time on a change that works. --- common/storage/queue_swap_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/storage/queue_swap_test.go b/common/storage/queue_swap_test.go index 6d253363..60c64f0a 100644 --- a/common/storage/queue_swap_test.go +++ b/common/storage/queue_swap_test.go @@ -33,6 +33,16 @@ func swapMsg() corestorage.Messager { // The difference is only visible during that wait, which is why the test holds // a consumer rather than checking the state after Setup has returned: by then // the two orders look identical. +// +// One refusal survives the fix and is not something this ordering can reach. +// GetQueuePrefix hands back a wrapper that captured the adapter, so a producer +// that fetched before the swap and appends after Shutdown has begun is still +// holding the old one. That window is one call wide and closing it means +// resolving the adapter inside Append, which is core's to change. What the +// ordering removes is the sustained window: every producer that fetches during +// the wait. The test publishes from a single goroutine, so at most one of its +// calls can straddle the swap - which is what makes "more than one" the line +// between the two orders rather than a tolerance. func TestAReloadNeverPointsProducersAtAClosedQueue(t *testing.T) { prevQ, prevC := config.QueueConfig, config.CacheConfig prevRuntime := sdk.Runtime @@ -107,7 +117,7 @@ func TestAReloadNeverPointsProducersAtAClosedQueue(t *testing.T) { if attempts.Load() == 0 { t.Fatal("nothing was published during the reload; the test proves nothing") } - if n := refused.Load(); n > 0 { + if n := refused.Load(); n > 1 { t.Errorf("%d of %d publishes during the reload were refused: producers were pointed at the closed queue", n, attempts.Load()) }