Repository navigation
fix: close client after query transport errors - #1203
OrangeFlag wants to merge 14 commits into
Conversation
|
@kavirajk please take a look when you have time |
|
@chernser, maybe you could take a look? |
|
@kavirajk, could you please review this when you have a moment? The race in the regression test is fixed, and CI is green. |
|
Hi @kavirajk, could you review this PR when you have a moment? |
3652572 to
ff7cf51
Compare
AI review gate — auto-approval withheldThe AI review gate is green, but the approver did not approve What to do: ask someone with write access who is not the PR author to approve this pull request. |
|
Hi @kavirajk, could you take another look at this PR when you have a moment? |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 220636c. Configure here.
AI review gate — AI review passedClean review from: Cursor Bugbot. |
a0e82c3 to
f41da7a
Compare

Fix query cleanup so
chpoolcannot reuse a connection with an unread or partially written stream. Transport, protocol and callback failures close the connection. Pending writes are interrupted on cancellation; connections with failed or incomplete sends are closed.A valid ClickHouse exception leaves the connection reusable after a successful write, including when the sending goroutine has not yet recorded completion. The decoded server exception remains available through
IsErr/AsExceptionif interrupting an incomplete send also produces a transport error.Regression tests cover read/write failures, blocked writes, cancellation with write deadlines, buffered input, callback errors and real-server exception recovery during delayed write completion.
Checklist
Note
Medium Risk
Changes core query/ping/flush error handling and when connections close versus stay reusable; incorrect logic could drop valid pooled connections or leave broken ones open.
Overview
Hardens connection lifecycle after failed or interrupted protocol exchanges so pooled clients are not reused with stale partial reads/writes.
flushnow usescontext.AfterFuncto force write deadlines on cancellation, aggregate errors withmultierr, and close the connection when deadline manipulation fails—without tearing down a conn whose write already completed.PingandDodocument and enforce: close on transport/protocol/callback failures and incomplete sends; keep the connection open when the query fully sent and the server returned a decodable exception.DotrackssendCompleteanddecodedException, closes early when input never ships (e.g. missing column info), and preserves exception errors even when cancellation interrupts pending writes.Extensive regression tests cover canceled/blocked writes, read timeouts, transport errors, buffered input during exceptions, and reuse after a successful write plus server exception.
Reviewed by Cursor Bugbot for commit 9577258. Bugbot is set up for automated code reviews on this repo. Configure here.