Found in manager/state/store/memory_test.go lines 2036-2054
for c := 0; c != 5; c++ {
wg.Add(1)
go func() {
defer wg.Done()
for i := 0; i < b.N; i++ {
_ = s.Update(func(tx1 Tx) error {
_ = UpdateNode(tx1, &api.Node{
ID: nodeIDs[i%benchmarkNumNodes],
Spec: api.NodeSpec{
Annotations: api.Annotations{
Name: nodeIDs[i%benchmarkNumNodes] + "_" + strconv.Itoa(c) + "_" + strconv.Itoa(i),
},
},
})
return nil
})
}
}()
}
Loop variable c is used within the func literal (in the statement strconv.Itoa(c)), possibly leading to a data race, causing all loop iterations to use the same value of c as mentioned here.
Two possible fixes:
- Pass
c as a param in the func literal
go func(c int) {
...
}(c)
- Create a new variable
for c := 0; c != 5; c++ {
...
x := c
go func() {
...
Name: nodeIDs[i%benchmarkNumNodes] + "_" + strconv.Itoa(x) + "_" + strconv.Itoa(i),
...
}
}
Found in
manager/state/store/memory_test.golines 2036-2054Loop variable
cis used within the func literal (in the statementstrconv.Itoa(c)), possibly leading to a data race, causing all loop iterations to use the same value ofcas mentioned here.Two possible fixes:
cas a param in the func literal