-
Notifications
You must be signed in to change notification settings - Fork 12
DRIVERS-3256 Fix PortPool uniqueness when used in multiple threads #320
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
Conversation
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.
LGTM!
Actually, can you update the changelog readme and the version so I can tag and release? |
Update: I was able to reproduce the bug locally by using python3.13t and increasing the number of servers:
Spoiler is this bugfix doesn't resolve the issue. PortPool itself is not thread safe so we have to introduce a lock there as well. |
Resolved the race:
Also updated the readme and version to 0.11.1. |
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.
LGTM, thanks!
DRIVERS-3256 Make Singleton thread safe to fix PortPool uniqueness
Note I could not reproduce the error reported in the ticket but my theory is that Singleton was not thread safe so it was possible that 2 servers started in 2 threads could create 2 different PortPool instances and therefor both yield the same port. A lock fixes this problem.
Update: I was able to reproduce the bug locally by using python3.13t and increasing the number of servers:
PortPool itself is also not thread safe so I had to utilize a lock there as well.