-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix connectivity state transitions when dialing #1596
Conversation
@menghanl thanks for making this change. Do you think it deserves a test? |
ab4e042
to
d24a10a
Compare
d24a10a
to
3ba27f2
Compare
I removed the |
call_test.go
Outdated
@@ -285,7 +285,7 @@ func TestInvokeCancelClosedNonFailFast(t *testing.T) { | |||
req := "hello" | |||
ctx, cancel := context.WithCancel(context.Background()) | |||
cancel() | |||
if err := Invoke(ctx, "/foo/bar", &req, &reply, cc, FailFast(false)); err == nil { | |||
if err := Invoke(ctx, "/foo/bar", &req, &reply, cc); 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.
this test is called TestInvokeCancelClosedNonFailFast
- did you mean to make this change?
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.
Good catch. Reverted.
clientconn.go
Outdated
@@ -904,15 +890,17 @@ func (ac *addrConn) errorf(format string, a ...interface{}) { | |||
|
|||
// resetTransport recreates a transport to the address for ac. The old | |||
// transport will close itself on error or when the clientconn is closed. | |||
// | |||
// The connectivity state of ac will be set to TransientFailure if it's not |
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.
Is this accurate? It seems that ac.state
will be set to connectivity.Connecting
unconditionally and then to connectivity. TransientFailure
on every attempt; I can't tell which part of this is sensitive to "if it's not first time doing resetTransport."
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 state is set by transportMonitor
to TransientFailure
before this function is called.
I removed this comment and add a comment in transportMonitor
.
Can you guys cut 1.7.1 with this? |
@tamird Will do it this week. |
This commit cherry-picked the connectivity state change from b3ed81a, excluding the connect() function cleanup.
The connectivity for addrConn goes from
Connecting
toTransientFailure
and back toConnecting
when dialing. This causes the first RPC to fail if it's not wait-for-ready. This PR makes addrConn skip the firstTransientFailure
if it's dialing.