-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
xds/ringhash: make reconnection logic work for a single subConn #5601
Conversation
On the other hand, this will cause RPC churn if the effective state of the ring hash hasn't changed as a result of the subconn state change. I.e. if the transition is from TF to IDLE, we can kick the subconn into CONNECTING (presumably that's the right thing to do) but not produce a new picker, because sticky-TF means that nothing has changed. If it doesn't add too much complexity to the code and isn't too much work, it would be nice to suppress updates where we know they are unnecessary. |
@@ -161,11 +163,13 @@ func (sc *subConn) queueConnect() { | |||
defer sc.mu.Unlock() | |||
sc.attemptingToConnect = true | |||
if sc.state == connectivity.Idle { | |||
sc.logger.Infof("Executing a queued connect for subConn in state: %v", sc.state) |
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.
Logging the exact same text here could make it hard to distinguish which operation is occurring. Did we just queue the connect attempt, or was it queued when the subconn went IDLE? Maybe this distinction is unimportant?
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.
The connection attempt is queued (by calling queueConnect()
method) from UpdateSubConnState()
when we want to start connecting on the next available subConn.
But this queueConnect()
method actually starts connecting only if the subConn is in IDLE
. For all other states, it set the connectQueued
bit to true, and when that subConn eventually transitions to IDLE
, the connect attempt is made. See setState()
which is called from UpdateSubConnState()
.
I think the distinction is not important here, whether the connection attempt happened right when it was queued or when it eventually moved to IDLE. What do you think?
Undid these changes after an offline discussion. |
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.
Thanks for the review.
@@ -161,11 +163,13 @@ func (sc *subConn) queueConnect() { | |||
defer sc.mu.Unlock() | |||
sc.attemptingToConnect = true | |||
if sc.state == connectivity.Idle { | |||
sc.logger.Infof("Executing a queued connect for subConn in state: %v", sc.state) |
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.
The connection attempt is queued (by calling queueConnect()
method) from UpdateSubConnState()
when we want to start connecting on the next available subConn.
But this queueConnect()
method actually starts connecting only if the subConn is in IDLE
. For all other states, it set the connectQueued
bit to true, and when that subConn eventually transitions to IDLE
, the connect attempt is made. See setState()
which is called from UpdateSubConnState()
.
I think the distinction is not important here, whether the connection attempt happened right when it was queued or when it eventually moved to IDLE. What do you think?
for ; ctx.Err() == nil; <-time.After(defaultTestShortTimeout) { | ||
if cc.GetState() == connectivity.Idle { | ||
break | ||
} | ||
} |
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.
Code golf:
for ; ctx.Err() == nil && cc.GetState != connectivity.Idle; <-time.After(...) {}
But why not use the connectivity state API? :
for state := cc.GetState(); state != connectivity.Idle && cc.WaitForStateChange(ctx, state); state = cc.GetState() {}
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.
Done.
Summary of changes:
Fixes #5594
RELEASE NOTES: