-
Notifications
You must be signed in to change notification settings - Fork 2.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
[extension/jaegarremotesamplingextension/internal] fix leaking goroutine on shutdown #31278
[extension/jaegarremotesamplingextension/internal] fix leaking goroutine on shutdown #31278
Conversation
Signed-off-by: Chirag Ghosh <[email protected]>
Signed-off-by: Chirag Ghosh <[email protected]>
I had to make the Shutdown function wait for the goroutine to finish because there is no way to force stop it. The Stop() function should close all connections while still waiting for the GracefulStop() to finish execution. |
@@ -99,6 +99,7 @@ func (s *SamplingGRPCServer) Shutdown(ctx context.Context) error { | |||
select { | |||
case <-ctx.Done(): | |||
s.grpcServer.Stop() | |||
<-ch // wait for the graceful stop goroutine to return |
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.
what is the pattern used by OTLP server in main collector repo? We should use the same mechanisms
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 only grpc implementation I found was in the otlp receiver here. It uses a waiting group which gets complete when the server is actually stopped after calling GracefulStop()
. So, it does not take into account the context timeout as found in our code. Should I change the implementation to match this?
P.S. This is also how all the receivers using grpc are configured in the contrib repository (including jaeger-receiver)
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.
sgtm - if it works for the exporter which is most likely used in 100% of configurations, why does this one needs to be more elaborate for shutdown.
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.
Pushed the changes. Do we need to tweak the tests?
Signed-off-by: Chirag Ghosh <[email protected]>
I think it's okay to skip adding a changelog here as even though it's a bug fix, it's an internal package. |
Co-authored-by: Curtis Robert <[email protected]>
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
Description: Fix goroutine leak on grpc server shutdown
Link to tracking Issue: #31157
Testing: Add goleak check for internal package. Run make test at module level.
Documentation: