- Notifications
You must be signed in to change notification settings - Fork1k
Commitee35ad3
authored
fix: remove hold WaitGroup in TestConcurrentFetch (#19617)
Fixes:coder/internal#950Pretty sure the intention of the `hold` wait group is to try to get the two goroutines that the test starts running at the same time. But, that should be the case for two goroutines started anyway.The use of `hold` doesn't actually guarantee concurrent execution of `Acquire`, just that both goroutines get as far as `Done()` --- the go scheduler could run them serially without incident.So I've chosen to just remove the use of `hold` to simplify.But, for posterity, the data race was due to incrementing by 1 in the loop along with the goroutine that calls Done. You could increment by 1 and then back down to 0 before the second iteration of the loop starts. This then causes a data race with calling `Wait()` in the first goroutine and `Add()` in the second iteration. c.f.https://pkg.go.dev/sync#WaitGroup.Add1 parent6606d8b commitee35ad3
1 file changed
+3
-9
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
100 | 100 |
| |
101 | 101 |
| |
102 | 102 |
| |
103 |
| - | |
104 |
| - | |
105 |
| - | |
106 |
| - | |
| 103 | + | |
107 | 104 |
| |
| 105 | + | |
108 | 106 |
| |
109 |
| - | |
110 | 107 |
| |
111 |
| - | |
112 | 108 |
| |
113 | 109 |
| |
114 |
| - | |
115 |
| - | |
116 | 110 |
| |
117 |
| - | |
| 111 | + | |
118 | 112 |
| |
119 | 113 |
| |
120 | 114 |
| |
|
0 commit comments
Comments
(0)