Skip to content
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

Fix race condition obtaining an authorization key in meetup/client.go #11

Open
fredlawl opened this issue Sep 13, 2022 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@fredlawl
Copy link
Contributor

Locks are effective at guarding access to resource read/writes, but the problem here is that the code does not currently consider a HTTP request to refresh a token a protected resource. We can enter into a race if a two calls to the client happen at the same time where caller A makes a request to refresh the token at the same time caller B makes a call to refresh the token. If caller A finishes first, then that token is now invalid. Caller B will have a valid token at that point, or could fail the request.

I don't have a good solution at the top of my head other than to lock everything up, and make sure the request timeouts at roughly a second or less to not hold up any threads accessing the next token too much.

Another idea is to leverage effective-go's channels and work out a solution with those. At the present time, this race is very tricky to trigger (requires much-greater scale to really hit it), so submitting an issue here as a reminder to take care of it.

@fredlawl fredlawl added the bug Something isn't working label Sep 13, 2022
@fredlawl fredlawl self-assigned this Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant