Conversation
1. RoundTripper contract violation (internal/client/client.go, errorHandler). On retry exhaustion it returned (resp, werr) with both non-nil. retryablehttp hands that straight to Go's net/http, which at net/http/client.go:262 logs "RoundTripper returned a response & error; ignoring response", discards the response, and leaks the connection — later surfacing as connection is already closed. 2. Fragile poll loop (connection.go, pollOperation). Long queries are driven by a 1s poll of GetOperationStatus. A single failed poll (idle timeout, reset, 5xx, EOF) made the sentinel abort the whole query — even though the operation handle is still valid server-side and the query keeps running. This is what "loses the statement handle." Changes made: - errorHandler now drains + closes the body and returns (nil, werr) — honoring the contract, matching retryablehttp's own default, and preserving the enriched error (reason-phrase headers). - pollOperation now swallows transient GetOperationStatus errors and keeps polling, bounded by a new maxPollFailureWindow = 5 * time.Minute (so a genuinely-dead warehouse still terminates), and aborts immediately on context cancellation/deadline. - Added tests: TestErrorHandler (nil response + body closed) and a TestConn_pollOperation subtest (recovers from a transient error instead of aborting). Test verification - TestErrorHandler, TestRetryPolicy, and all TestConn_pollOperation subtests pass (including the new resilience test). Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.
Changes made:
Test verification