-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential race between Redis key TTL and Context.Reset? #94
Comments
Hello, Can you give me a gist with a full example on how you initialize the store, what period do you use, what code do you execute after Thank you. |
Here's what I could come up with @novln. I was able to reproduce with rates of 1-S and 1-M. I've also attached the code + go.mod/go.sum files. https://gist.github.com/Xopherus/7423f7b2b60264b94bb9dd5c9ebe9c7d |
Ok I'm able to reproduce that, thank you for the gist. I think the issue is how we compute the Cheers, |
Because the expiration is somewhat imprecise between the I won't fix this issue (for the moment) because it means a refactoring that I don't want to manage. With that being said, I'll gladly review pull request. Cheers, |
I'm seeing what seems to be a race condition where the limiter key is still present in the Redis store after the code waits for
Context.Reset
to be reached. This causes the next iteration of the code to also be rate-limited, butContext.Reset
is already past, so the sleep duration is negative.Been seeing this with the following:
Here's a snippet of the code which should be able to reproduce it:
And here are the logs:
Can anyone else reproduce this?
The text was updated successfully, but these errors were encountered: