Skip to content

Commit

Permalink
Merge #131305
Browse files Browse the repository at this point in the history
131305: testutils: data race when TestCluster fails to start r=tbg a=vidit-bhat

Previously, we were running into a race condition due to the access of the `stores` map in the error reporting inside the timeout logic. This patch fixes this by reporting the error after grabbing a lock on `stores`.

Epic: none
Fixes: #87592
Release note: None

Co-authored-by: Vidit Bhat <[email protected]>
  • Loading branch information
craig[bot] and vidit-bhat committed Sep 25, 2024
2 parents e1b5321 + 6d11799 commit cbc681e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/testutils/testcluster/testcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,11 @@ func (tc *TestCluster) WaitForNStores(t serverutils.TestFataler, n int, g *gossi
}
t.Fatal(err)
case <-time.After(testutils.DefaultSucceedsSoonDuration):
t.Fatalf("timed out waiting for %d store descriptors: %v", n-seen, stores)
func() {
storesMu.Lock()
defer storesMu.Unlock()
t.Fatalf("timed out waiting for %d store descriptors: %v", n-seen, stores)
}()
}
}
}
Expand Down

0 comments on commit cbc681e

Please sign in to comment.