-
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
balancer: make sure non-nil done returned by Pick is called #2688
Conversation
Special case: when SubConn returned by Picker is not Ready, call done before looping back to re-pick.
picker_wrapper.go
Outdated
@@ -165,6 +165,14 @@ func (bp *pickerWrapper) pick(ctx context.Context, failfast bool, opts balancer. | |||
} | |||
return t, done, nil | |||
} | |||
if done != nil { | |||
done(balancer.DoneInfo{ | |||
Err: nil, |
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.
These are all the defaults - maybe delete and a comment "default DoneInfo indicates RPC did not occur"?
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.
If the field was named NoBytesSent
, we would want to set it to true
(It's great that's not the case :) )
Deleted and explain in a comment.
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.
Didn't test this because returning a non-Ready SubConn from picker is very racy.
test/balancer_test.go
Outdated
// Stop server and at the same time send RPCs. There are chances that picker | ||
// is not updated in time, causing a non-Ready SubConn to be returned. | ||
var wg sync.WaitGroup | ||
wg.Add(1) |
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 loneliest waitgroup. Maybe use a channel instead?
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
Special case: when SubConn returned by Picker is not Ready, call done before
looping back to re-pick.