diff --git a/internal/upstream/limiter/limiter_test.go b/internal/upstream/limiter/limiter_test.go index 3748ec112..97fc4a511 100644 --- a/internal/upstream/limiter/limiter_test.go +++ b/internal/upstream/limiter/limiter_test.go @@ -654,6 +654,14 @@ func (c *parkedCall) release(t *testing.T) { // calls parked in whatever slot they win, freeing the held slot can put exactly // ONE of them past admission, so the two admissions can never be reported // concurrently and the order the test reads is the order the limiter granted. +// +// Parking is what makes that true, and it is the whole point of the helper. An +// earlier version had each caller release as soon as it was admitted, which is +// the very thing that wakes the next waiter: both callers then finished while +// the test was still parked, both result channels went ready at once, and the +// select below picked between them at random. That measured which goroutine got +// scheduled first, not which one the limiter granted first, and it failed on +// loaded runners for no reason at all. func TestFastPathDoesNotOvertakeAQueue(t *testing.T) { l := New(ScopeServer, "srv", Limits{Max: 1, QueueSize: 4, QueueTimeout: time.Hour})