From d8b220319d0391a8eb33f0610ddf85932eeebb2b Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Wed, 18 Nov 2026 15:38:49 -0800 Subject: [PATCH] test(query): leave the abandoned-run test only after its run starts The test cancelled its caller once the flight registered, before the run marked its read slot. A run still queued when its last caller leaves is cancelled by design, so the next lookup missed. Wait for the run to start, as the coalescing test does. --- internal/query/result_cache_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/query/result_cache_test.go b/internal/query/result_cache_test.go index ed812678..2398a575 100644 --- a/internal/query/result_cache_test.go +++ b/internal/query/result_cache_test.go @@ -541,9 +541,11 @@ func TestResultCacheAbandonedRunsCompleteAndAreReused(t *testing.T) { release := make(chan struct{}) gone, leave := context.WithCancel(t.Context()) left := make(chan error, 1) + entered := make(chan struct{}) go func() { _, _, err := loadCached(e, gone, cacheKey{3}, e.now(), func(run context.Context) (int, int64, bool, error) { markStarted(run) // the run holds a read slot + close(entered) select { case <-release: return 5, 8, true, nil @@ -553,7 +555,8 @@ func TestResultCacheAbandonedRunsCompleteAndAreReused(t *testing.T) { }) left <- err }() - waitForFlight(t, e, cacheKey{3}) + // Leave only once the run has started: a queued run is cancelled instead. + <-entered leave() if err := <-left; !errors.Is(err, context.Canceled) { t.Fatalf("departed caller err=%v", err)