-
Notifications
You must be signed in to change notification settings - Fork 49
Fix dead locks in connection pool #499
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 dead locks in connection pool #499
Conversation
and pool Locking connection and pool at the same time can lead to deadlock. Consider that connection.close also locks connection.
pool Locking connection and pool can lead to deadlock. Consider that connection.close locks connection.
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.
Eh, I don't understand this code well enough to say with confidence that those changes are correct. At first glance they look correct, left just one comment about improving commit message.
I wish it was written in a more dev-friendly way: one thread/task/whatever than handles connection / pool, receives events etc. Then there is basically no need for any locks, since things only have one owner.
and pool Locking connection a pool can lead to a deadlock. Consider that connection.close also locks connection. This commit also fixes condition for closing connection right away. Instead of checking there is no in-flight requests it now checks if in-flight requests less or equal than orphaned requests, since orphaned requests still counts as in-flight and can be safely disregarded when connection is dropped.
and connection Locking connection and pool at the same time lead to dead lock. Consider connection.close locks connection.
161c996
to
729f9cc
Compare
We could have rewritten it, but I think it would be way better to invest into the wrapper around rust-driver. |
Investigating problems with scaling test for #473 I have found dead locks in both pools implementations:
HostConnection
andHostConnectionPool
All these deadlocks caused by following reasons:
Solution to all of them is to avoid locking pool and session at the same time.
Tests were not added because for most cases there could be no reliable test possible.
Pre-review checklist
I added relevant tests for new features and bug fixes.I have provided docstrings for the public items that I want to introduce.I have adjusted the documentation in./docs/source/
.I added appropriateFixes:
annotations to PR description.