Skip to content

Commit 5a18d88

Browse files
craig[bot]mw5h
craig[bot]
andcommitted
140953: vecindex: deflake TestVectorManager r=mw5h a=mw5h The multithreaded vector manager test was innappropriately capturing an index variable, leading to occasional failures in extended CI. This patch moves that index variable into a passed argument. Epic: CRDB-42943 Co-authored-by: Matt White <[email protected]>
2 parents d65ba4b + 1d4c348 commit 5a18d88

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/sql/vecindex/manager_test.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ func TestVectorManager(t *testing.T) {
192192
})
193193

194194
t.Run("test multiple threaded erroring", func(t *testing.T) {
195+
ctx, cancel := context.WithCancel(context.Background())
196+
defer cancel()
197+
195198
pullDelayer := sync.WaitGroup{}
196199
pullDelayer.Add(10)
197200
testingKnobs := vecindex.VecIndexTestingKnobs{
@@ -207,10 +210,10 @@ func TestVectorManager(t *testing.T) {
207210
wg := sync.WaitGroup{}
208211
for i := 0; i < 11; i++ {
209212
wg.Add(1)
210-
go func() {
213+
go func(idx int) {
211214
defer wg.Done()
212-
_, errs[i] = vectorMgr.Get(ctx, 142, 4)
213-
}()
215+
_, errs[idx] = vectorMgr.Get(ctx, 142, 4)
216+
}(i)
214217
}
215218
wg.Wait()
216219
require.Error(t, errs[0])

0 commit comments

Comments
 (0)