fix(state/txclient): close estimator conn on failure and wait for Ready#5073
Open
neyy91 wants to merge 1 commit into
Open
fix(state/txclient): close estimator conn on failure and wait for Ready#5073neyy91 wants to merge 1 commit into
neyy91 wants to merge 1 commit into
Conversation
setupEstimatorConnection created a *grpc.ClientConn, called Connect, then returned an error without closing it when the endpoint was unreachable. setupClient retries on each submit while the client is uninitialized, so an unreachable estimator leaked one conn (resolver/balancer goroutines and transport) per attempt. Additionally, WaitForStateChange(ctx, Ready) waits for the connection to transition away from the given state, not into it. A fresh conn starts in Idle/Connecting, so the call returned immediately and never actually waited for Ready, returning a non-connected conn with a nil error and ignoring the context deadline. Close the conn on the failure path and add waitForReady, which loops over the current state until Ready or the context is done.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5073 +/- ##
==========================================
- Coverage 44.83% 36.62% -8.21%
==========================================
Files 265 311 +46
Lines 14620 21506 +6886
==========================================
+ Hits 6555 7877 +1322
- Misses 7313 12622 +5309
- Partials 752 1007 +255 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes two related defects in
setupEstimatorConnection:gRPC connection leak - the conn was created and
Connect()-ed but returned withoutClose()on the failure path. SincesetupClientretries on each submit while the client is uninitialized, an unreachable estimator leaked one conn (resolver/balancer goroutines + transport) per attempt.Ready was never awaited -
WaitForStateChange(ctx, Ready)waits for transition away from the given state. A fresh conn is inIdle/Connecting, so the call returned immediately and the function handed back a non-connected conn with a nil error, ignoring the deadline.Changes
waitForReady, which loops over the current state untilReadyor the context is done.Closes #5072
Testing
go test ./state/txclient/ -race- green.