-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
connpool: fix racy test #14731
connpool: fix racy test #14731
Conversation
Signed-off-by: Vicent Marti <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
// block until we have a client wait for a connection, then offer it | ||
for p.wait.waiting() == 0 { | ||
time.Sleep(time.Millisecond) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should use a context here to break out of this if needed... but this is a unit test so the test itself should time out relatively quickly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory this code cannot deadlock, because the goroutine is constantly trying to add itself to the waitgroup, but you're right that the test timeout will catch this if down the road we break the implementation.
Signed-off-by: Vicent Marti <[email protected]>
Description
Spotted by @harshit-gangal. A sleep is not always enough to synchronize the wait. We can make the synchronization explicit by waiting until a client is in the wait queue, then offering a connection to them.
Related Issue(s)
Checklist
Deployment Notes