-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
lib/connections: More fine grained locking (fixes #3066) #3069
Conversation
This fixes the deadlock by reducing where we hold the various locks. To start with it splits up the existing "mut" into a "listenersMut" and a "curConMut" as these are the two things being protected and I can see no relation between them that requires a shared lock. It also moves all model calls outside of the lock, as I see no reason to hold the lock while calling the model (and it's risky, as proven).
So this potentially brings back the connected to already connected issue, if we don't lock around AddConnection and ConnectedTo |
How does that happen, again? |
T1 in redial checks connectionType map, no value |
So if one connection comes in at the same time as we're dialing, one will get hit by "already connected" which is fine? We could reduce the window a bit though as |
I am as always on my phone so hard to have a proper discussion, though what you are saying sounds like true. I think the caching discovery mux absorbs the frequent lookups? |
Some of them, but I think it still lets through a global discovery query per five or ten minutes or something. But that's an easy optimization for another commit. :) |
So whats the plan? Are we pushing this and following it up or whats the plan. |
@st-review merge |
From my POV yes as it fixes the problem I see, and I don't think I see the other problem if it's here. :) |
This fixes the deadlock by reducing where we hold the various locks. To start with it splits up the existing "mut" into a "listenersMut" and a "curConMut" as these are the two things being protected and I can see no relation between them that requires a shared lock. It also moves all model calls outside of the lock, as I see no reason to hold the lock while calling the model (and it's risky, as proven). GitHub-Pull-Request: #3069
Well the other problem is definately there, as thats what I tried to fix by using wider scope for the locks. |
I remember that issue being about us not switching connections properly. I'll see if I can find it later. |
Purpose
This fixes the deadlock by reducing where we hold the various locks. To
start with it splits up the existing "mut" into a "listenersMut" and a
"curConMut" as these are the two things being protected and I can see no
relation between them that requires a shared lock. It also moves all
model calls outside of the lock, as I see no reason to hold the lock
while calling the model (and it's risky, as proven).
Testing
Things connect, now.