Commit 5ef874c
authored
fix(sync):
causing flaky tests.
Reorder counter updates relative to semaphore
ops to prevent race condition where `Current()`
could temporarily exceed 2485582size+12485582.
* `Add()`: inc counter before acquiring semaphore
* `Done()`: dec counter before releasing semaphore
This eliminates the race window where both `Add()`
and `Done()` had pending counter updates, causing
`TestThrottling` to fail in CI with `Current()`
reaching 6-7 instead of expected max. of 5
(size=4).
Signed-off-by: Dwi Siswanto <[email protected]>AdaptiveWaitGroup counter racy (#701)1 parent a911e35 commit 5ef874c
1 file changed
+4
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
| 74 | + | |
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
76 | | - | |
77 | 79 | | |
78 | | - | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | | - | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
0 commit comments