-
Notifications
You must be signed in to change notification settings - Fork 806
Move updating connectivity state outside of subchannel lock #2601
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
81ad06f
to
35edd39
Compare
@@ -264,6 +266,11 @@ public void RequestConnection() | |||
} | |||
} | |||
|
|||
if (connectionRequested) | |||
{ | |||
UpdateConnectivityState(ConnectivityState.Connecting, "Connection requested."); |
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.
Is this now going to cause races where someone else comes along and modifies the Subchannel state and we end up updating it to Connecting
when it should stay as TransientFailure
or Ready
?
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 believe this is fine. The logic in load balancing is designed that state can change at any point, and other parts of the system then react to it. All other places update the connectivity state outside the subchannel lock, this one is the outlier.
Would this be the cause of this reported issue? #2612 |
Fixes #2589
In connection manager and friends there are two important types of lock:
It's safe to take a subchannel lock inside the connection manager lock, but doing the opposite can lead to a deadlock.
There is one place locks were taken in the incorrect order which could cause a deadlock in rare circumstances: the channel is pick first, it has an idle subchannel, and a connection request occurs at the same time as the resolver updates.
Repoed in a unit test:
The fix is to move the connectivity state update outside of the subchannel lock.