-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Workload Resilience
-
Fully Compatible
-
ALL
-
Workload Resilience 2026-02-16
-
0
-
None
-
None
-
None
-
None
-
None
-
None
-
None
The ConcurrentTokenAcquisitionWithQueueing involves queueing a few threads waiting for a token, advancing the mocked clock by the time it takes to acquire a token, and verifying that a token is dispensed after each advance.
This doesn't quite match the implementation of the underlying token bucket though, which isn't fully synchronized. Queuing is implemented by "borrowing" tokens that don't exist in the token and returning a "nap time" that the borrower has to sleep in order for the borrow to have been valid due to token refill. Since this isn't synchronized, two threads that borrow at the same time might calculate the same nap time since they both observe each others borrows, despite the fact that one could actually wake up earlier.
This discrepancy isn't a bug though, since the rate is still respected when amortized over a large enough time and a large enough acquisitions. For example, in the above case the average rate will still be the configured one over 2*refillPeriod, but both tokens will be acquired at the end of that period instead of smoothly.
We should relax the test assertions to not assume smooth token acquisition to account for this.