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

[exporter/loadbalancing] Do not block resolver by the exporter shutdown #31602

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion exporter/loadbalancingexporter/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ func (lb *loadBalancer) removeExtraExporters(ctx context.Context, endpoints []st
}
for existing := range lb.exporters {
if !endpointFound(existing, endpointsWithPort) {
_ = lb.exporters[existing].Shutdown(ctx)
exp := lb.exporters[existing]
// Shutdown the exporter asynchronously to avoid blocking the resolver
go func() {
_ = exp.Shutdown(ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with this, but isn't it cleaner to use context.WithTimeout wrapping the context? Would Shutdown respect the timeout?

Copy link
Member Author

@dmitryax dmitryax Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what's the need for this. With all the locks this shutdown can block consumes which supposed to be handled by other available sub-exporters. If we kill it by timeout, we introduce the same panics back. I think we should mark the sub-exporter as "turned off" and shut it down asynchronously once it handles all the current requests.

}()
delete(lb.exporters, existing)
}
}
Expand Down
Loading