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
loopyWriter continuing to run after GracefulStop causing race with t.Log #6485
Comments
We do the same thing in our tests. 😄 It looks like
|
@dfawley thanks a lot for your help. Yes, Why should using Does t.Stop() maybe prevent that an error happens that the loopyWriter go-routine will log? |
Interesting.. I was thinking Line 1862 in b8d36ca
grpc-go/internal/transport/http2_server.go Line 1238 in b8d36ca
|
Also our tests may not run into this because we also always use: https://pkg.go.dev/google.golang.org/grpc@v1.57.0/internal/leakcheck |
I'll give it a try and create a PR if it works out. Update: PR is out: #6489 |
Yes, leakcheck does not detect it because it only complains if a go-routine is still running after 10s after the test terminated. |
Hello,
we are starting a grpc-server in a Go testserver.
On test finish we call
Server.GracefulStop()
viat.Cleanup()
.We forward all log messages from the grpc packages to the test logger, by setting
grpclog.SetLoggerV2
to at.Log
wrapper.When we run the tests with the
-race
parameter, it happens from now and then that a race is detected because loopyWriter logs a message tot.Log()
after the test finish.As I understand
Server.GracefulStop()
does not wait until the loopyWriter go-routine has terminated.The message that is logged after test termination from loopyWriter happens here:
grpc-go/internal/transport/controlbuf.go
Line 543 in b8d36ca
GracefulStop
.Is there a way to wait in a testcase until loopyWriter terminated that I'm missing?
If not, shouldn't it be possible to do a termination that ensures no go-routines are running afterwards?
This would also e.g. work well together with https://github.com/uber-go/goleak, that checks if any go-routines are leaked in a testcase.
grpc-go version: 1.57
The text was updated successfully, but these errors were encountered: