-
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: cache connectivity state of subchannels inside picker #6351
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.
case connectivity.TransientFailure: | ||
// Save error to be reported via picker. | ||
b.connErr = state.ConnectionError | ||
b.regeneratePicker() | ||
case connectivity.Shutdown: | ||
// When an address was removed by resolver, b called RemoveSubConn but | ||
// kept the sc's state in scStates. Remove state for this sc here. | ||
delete(b.scStates, sc) |
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.
Nit: Not a part of this PR, but this scStates field I feel like is wrongly named. This is a map from balancer.SubConn to the Ring Hashes SubConn with extra info. I feel like states is only a part of the reason this map exists.
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.
Yeah it probably was changed during development. 99% of why there exists a map is state tracking. It also does a queueConnect
in rare cases.
case connectivity.Shutdown: | ||
// When an address was removed by resolver, b called RemoveSubConn but | ||
// kept the sc's state in scStates. Remove state for this sc here. | ||
delete(b.scStates, sc) | ||
} | ||
|
||
if sendUpdate { | ||
if oldSCState != newSCState { | ||
// Because the picker caches the state of the subconns, we always regnerate |
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.
regenerate
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.
Fixed
if sendUpdate { | ||
if oldSCState != newSCState { | ||
// Because the picker caches the state of the subconns, we always regnerate | ||
// and update the picker when the effective state changes. |
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.
Nit: "of the SubConn." Optional addition: "This is so the Client Conn gets the most updated state as a former picker has a static cache of SubConn states at it's build time."
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.
Fixed
I did not add a new test for this. The sequence of operations required here is fairly long and specific and requires races that are too difficult to reliably stimulate. Corresponding change in C++: grpc/grpc@
98cdac3
(#32326). (gRPC-Java always kept a copy of the states in the picker.)RELEASE NOTES: