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: Introduce GetStatus method to get the latest connection error #2055

Closed
wants to merge 1 commit into from

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented May 8, 2018

Fixes #2031

This may be just a proof of concept, but I think we will need something like this. A few things I noticed:

  • Is the "last connection error" a better fit alongside the connectivity state (like in Java) instead of within the blockingpicker?
  • We probably should either clear the latest connection error on any success (to prevent leaking the current error to a subsequent failure state), and/or be very sure it's always set freshly when the status of the channel goes to transient failure. I would definitely prefer to do the latter.
  • GetStatus() is racy because there is no lock. However, the user's code is unavoidably racy between noticing GetState() == TransientFailure and doing the GetStatus() call, so maybe it's fine?

@dfawley dfawley added the Type: Feature New features or improvements in behavior label May 8, 2018
@dfawley dfawley requested a review from menghanl May 8, 2018 22:18
@@ -877,6 +887,9 @@ func (cc *ClientConn) removeAddrConn(ac *addrConn, err error) {
return
}
delete(cc.conns, ac)
if len(cc.conns) == 0 {
cc.blockingpicker.updateConnectionError(errors.New("no backends returned by resolver"))
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the balancer wanted to remove the last addrConn from cc? It will also be zero in that case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't this that code path?

if cc.GetState() != connectivity.TransientFailure {
return nil
}
return status.Errorf(codes.Unavailable, "latest connection error: %v", cc.blockingpicker.connectionError())
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the advantage of using status error here?
What other error codes will we return?

Copy link
Member Author

Choose a reason for hiding this comment

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

It mirrors the Java API. That one returns a status directly, but I thought "error" would be more idiomatic for us.

@dfawley
Copy link
Member Author

dfawley commented Sep 6, 2018

Closing for now until I get a chance to revisit.

@dfawley dfawley closed this Sep 6, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Mar 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants