Closed cncal closed 1 year ago
/cc @bcmills @Sajmani
Change https://go.dev/cl/406154 mentions this issue: rate: the state of the limiter should not be changed when the requests failed
I think the correct value is 300ms
.
See https://go.dev/play/p/X_jeZbv_mRy?v=goprev which removes the line lim.ReserveN(t0, 3)
that causes the error.
Note that the burst is 2
so that at t1
before the request (lim.ReserveN(t1, 2).OK()
), there are 2
tokens in the bucket (instead of 3
).
Regarding the error caused by lim.ReserveN(t0, 3)
, I have sent a CL to fix it.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, it reproduces with go1.18.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://go.dev/play/p/vGnnjsqOcTp?v=goprev.
What did you expect to see?
I expect
r.Delay()
returns200ms
, just like https://go.dev/play/p/knb4-IPMUFd?v=goprev.What did you see instead?
r.Delay()
returns300ms
. Both of previous reservations are not ok, why the later reservation returns different delay.