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

[extension/jaegarremotesamplingextension/internal] fix leaking goroutine on shutdown #31278

Conversation

chirag-ghosh
Copy link

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:

Copy link

linux-foundation-easycla bot commented Feb 15, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@chirag-ghosh
Copy link
Author

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
Copy link
Member

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

Copy link
Author

@chirag-ghosh chirag-ghosh Feb 18, 2024

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)

Copy link
Member

@yurishkuro yurishkuro Feb 18, 2024

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.

Copy link
Author

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?

@crobert-1 crobert-1 added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Feb 26, 2024
@crobert-1
Copy link
Member

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]>
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Mar 20, 2024
@crobert-1 crobert-1 removed the Stale label Mar 20, 2024
Copy link
Contributor

github-actions bot commented Apr 4, 2024

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Apr 4, 2024
Copy link
Contributor

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension/jaegerremotesampling Skip Changelog PRs that do not require a CHANGELOG.md entry Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants