-
Notifications
You must be signed in to change notification settings - Fork 2.2k
query: introduce GC delay for gRPC conns #8585
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
Conversation
See query/endpointset.go for rationale. We currently immediately kill gRPC connections on Close() but they might still be used. :/ Wait until the query timeout duration before closing them. Signed-off-by: Giedrius Statkevičius <[email protected]>
78f4d8c to
2d770a9
Compare
Signed-off-by: Giedrius Statkevičius <[email protected]>
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.
Pull request overview
This pull request introduces a garbage collection delay mechanism for gRPC connections to prevent premature closure while connections might still be in use. The implementation adds a queryTimeout parameter to the EndpointSet constructor and delays connection closure by using the maximum of queryTimeout, endpointInfoTimeout, and unhealthyEndpointTimeout.
Key changes:
- Modified
EndpointSetto track agcTimeoutcalculated as the maximum of query, endpoint info, and unhealthy endpoint timeouts - Updated
endpointRef.Close()to accept agcDelayparameter and defer actual connection closure usingtime.AfterFunc - Added goleak ignore rules for gRPC connection goroutines that are intentionally delayed
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/query/endpointset.go | Added gcTimeout field to EndpointSet, modified Close() signature to accept delay parameter, implemented delayed closure using time.AfterFunc |
| pkg/query/endpointset_test.go | Updated test helper calls with new queryTimeout parameter, added TestEndpointCloseGCTime to verify GC delay behavior |
| cmd/thanos/query.go | Passed queryTimeout parameter to setupEndpointSet |
| cmd/thanos/rule.go | Passed evalInterval as query timeout to setupEndpointSet |
| cmd/thanos/endpointset.go | Added queryTimeout parameter to setupEndpointSet and passed it to NewEndpointSet |
| pkg/testutil/custom/custom.go | Added goleak ignore rules for gRPC connection goroutines that are not immediately reaped |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Looks like unit test failure is related to this change |
|
Added back synctest.Wait() so that the test would properly wait until the other goroutine closes the gRPC connection. I cannot reproduce the failure anymore even with |
Signed-off-by: Giedrius Statkevičius <[email protected]>
eb19d02 to
2f8c616
Compare
fpetkovski
left a comment
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.
🚀
See query/endpointset.go for rationale. We currently immediately kill
gRPC connections on Close() but they might still be used. :/ Wait until
the query timeout duration before closing them.
Signed-off-by: Giedrius Statkevičius [email protected]