The AdaptiveWaitGroup implementation contains a race window between semaphore ops and counter updates. Under certain interleavings, the Current() value can temporarily exceed $$size + 1$$.
This manifests as flaky CI failures, especially in TestThrottling, where Current() was observed reaching 6–7 even though the configured size is 4.
What’s happening?
Both Add() and Done() update the internal counter only after their respective semaphore ops. When both ops are inflight, rapid goroutine churn can result in:
Add() being counted too late.
Done() not being counted early enough.
Current() reading a transient inflated value.