Skip to content

Commit

Permalink
testutils: data race when TestCluster fails to start
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vidit-bhat committed Sep 24, 2024
1 parent 843b4e0 commit 6d11799
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 6d11799

Please sign in to comment.