Skip to content
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

clientconn: fix race when service config updated while closing #2371

Merged
merged 1 commit into from
Oct 11, 2018

Conversation

menghanl
Copy link
Contributor

@menghanl menghanl commented Oct 10, 2018

Closing ClientConn sets balancerWrapper to nil.
If service config switches balancer, the new balancer will be notified of the existing addresses.

When these two happens together, there's a chance that a method will be called on the nil balancerWrapper. This change adds a check to make sure that never happens.

fixes #2367

@menghanl menghanl changed the title clientconn: not panic when service config updateed while closing clientconn: not panic when service config updated while closing Oct 10, 2018
@@ -747,6 +747,10 @@ func (cc *ClientConn) handleServiceConfig(js string) error {
return err
}
cc.mu.Lock()
if cc.conns == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment here why we need this check, please. And please explain why we don't check cc.balancerWrapper instead?

@menghanl menghanl force-pushed the client_close_resolver_race_panic branch from eb5cfd8 to 3b16c59 Compare October 11, 2018 17:37
@menghanl menghanl merged commit cb11627 into grpc:master Oct 11, 2018
@menghanl menghanl deleted the client_close_resolver_race_panic branch October 11, 2018 18:43
@dfawley dfawley added this to the 1.16 Release milestone Oct 11, 2018
@menghanl menghanl changed the title clientconn: not panic when service config updated while closing clientconn: fix race when service config updated while closing Oct 23, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Apr 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic when close ClientConn
2 participants