-
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
transport : wait for goroutines to exit before transport closes #7666
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7666 +/- ##
==========================================
+ Coverage 81.85% 81.93% +0.08%
==========================================
Files 361 361
Lines 27822 27845 +23
==========================================
+ Hits 22773 22815 +42
+ Misses 3851 3837 -14
+ Partials 1198 1193 -5
|
Thanks for addressing my earlier comments, overall change LGTM but still I feel it'd be better to add e2e style tests to verify the same. |
Yes, I am working on the tests for it. |
We rely on leak check to detect if |
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.
Looks good in general. Mostly nits.
internal/transport/transport_test.go
Outdated
// Tests that client does not close until the reader goroutine exits and closes | ||
// once reader goroutine returns. |
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.
// Tests that client does not close until the reader goroutine exits and closes | |
// once reader goroutine returns. | |
// Tests that closing a client transport does not return until the reader goroutine exits. |
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.
internal/transport/transport_test.go
Outdated
// Tests that client does not close until the reader goroutine exits and closes | ||
// once reader goroutine returns. | ||
func (s) TestClientCloseReturnsAfterReaderCompletes(t *testing.T) { | ||
connectCtx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
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: s/connectCtx/ctx
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.
internal/transport/transport_test.go
Outdated
close(hangConn) | ||
select { | ||
case <-transportClosed: | ||
case <-time.After(defaultTestTimeout): |
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: why not use ctx.Done()
here? That will ensure that the whole test has only 10s to run.
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 change is somehow causing a race condition between TestClientCloseReturnsEarlyWhenGoAwayWriteHangs
and TestClientCloseReturnsAfterReaderCompletes
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.
Hmm... That is weird. Tests should be independent. Do you have an output from a failed run?
err := hc.Conn.Close() | ||
return err |
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: single line return hc.Conn.Close()
Fixes: #2869
Previously,
clientconn.Close()
did not guarantee termination of some goroutines upon return.Now,
clientconn.Close()
ensures that:readerDone
channel to signal completion ofreader
goroutine.keepAliveDone
channel to signal completion ofkeepAlive
goroutine.clientconn.Close()
waits for all transports to be closed before returning.RELEASE NOTES:
clientconn.Close()
waits for all transports to be closed before returning.