Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion internal/query/result_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Loading