Repository navigation
fix(warehouse): retire idle clickhouse v2 connections - #7352
Merged
Merged
Conversation
A v2 load commits one block per transaction, so every block takes a connection out of the pool. The pool had a size but no lifetime, so a connection the server closed while it sat idle stayed in it. BeginTx's health check is a cheap local check and passes; prepareBatch then does the first real I/O on that dead socket and fails. The driver turns it into driver.ErrBadConn, and because the connection is already bound to a transaction database/sql cannot swap it out the way it does for db.Query, db.Exec and db.Begin. The error surfaces to the caller as preparing statement INSERT INTO ...: driver: bad connection which fails the whole table load after however many blocks had already landed. Seen in production after 6,275,000 rows. connMaxIdleTime and connMaxLifetime retire those connections before a block picks one up. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4 🔒 Scanned for secrets using gitleaks 8.29.1
achettyiitr
force-pushed
the
fix.ch-v2-conn-lifetime
branch
from
September 8, 2026 08:50
6ccda27 to
e804982
Compare
ItsSudip
approved these changes
Sep 8, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/1.86.x #7352 +/- ##
=================================================
Coverage ? 79.95%
=================================================
Files ? 615
Lines ? 69136
Branches ? 0
=================================================
Hits ? 55279
Misses ? 10616
Partials ? 3241 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
saikumarrs
approved these changes
Sep 9, 2026
Merged
achettyiitr
pushed a commit
that referenced
this pull request
Sep 9, 2026
🤖 I have created a release *beep* *boop* --- ## [1.86.1](v1.86.0...v1.86.1) (2026-09-09) ### Bug Fixes * **warehouse:** instrument the clickhouse v2 load path ([#7355](#7355)) ([6456c64](6456c64)) * **warehouse:** pass temporary credentials to the clickhouse v2 s3 copy engine ([#7353](#7353)) ([c835fc0](c835fc0)) * **warehouse:** retire idle clickhouse v2 connections ([#7352](#7352)) ([3a1407c](3a1407c)) * **warehouse:** retry a failed clickhouse v2 block ([#7354](#7354)) ([72390f6](72390f6)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
atzoum
pushed a commit
that referenced
this pull request
Sep 9, 2026
# Description Syncing patch release v1.86.1 to main branch **↓↓ Please review and edit commit overrides before merging ↓↓** BEGIN_COMMIT_OVERRIDE fix(warehouse): retire idle clickhouse v2 connections (#7352) fix(warehouse): retry a failed clickhouse v2 block (#7354) fix(warehouse): pass temporary credentials to the clickhouse v2 s3 copy engine (#7353) fix(warehouse): instrument the clickhouse v2 load path (#7355) END_COMMIT_OVERRIDE --------- Co-authored-by: Akash Chetty <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
This was referenced Sep 14, 2026
Closed
Closed
atzoum
pushed a commit
that referenced
this pull request
Sep 14, 2026
🤖 I have created a release *beep* *boop* --- ## [1.87.0-rc.1](v1.86.0...v1.87.0-rc.1) (2026-09-14) ### Features * backend config shadow mode ([#7340](#7340)) ([4898165](4898165)) * bump rudder-go-kit and go modules to Go 1.27.1 ([#7345](#7345)) ([8d95c68](8d95c68)) * **router:** read transformerProxy from transformer features before env ([#7337](#7337)) ([e8f0ea6](e8f0ea6)) ### Bug Fixes * **router:** redact credentials from destination URLs in failure responses ([#7372](#7372)) ([14659bf](14659bf)) * **warehouse:** instrument the clickhouse v2 load path ([#7355](#7355)) ([4d743db](4d743db)) * **warehouse:** pass temporary credentials to the clickhouse v2 s3 copy engine ([#7353](#7353)) ([4d743db](4d743db)) * **warehouse:** retire idle clickhouse v2 connections ([#7352](#7352)) ([4d743db](4d743db)) * **warehouse:** retry a failed clickhouse v2 block ([#7354](#7354)) ([4d743db](4d743db)) ### Miscellaneous * **processor:** assemble side-PU report metrics at end of preprocess stage ([#7346](#7346)) ([4540876](4540876)) * sync release v1.86.0 to main branch ([#7356](#7356)) ([6868c6c](6868c6c)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
This was referenced Sep 14, 2026
Closed
atzoum
pushed a commit
that referenced
this pull request
Sep 14, 2026
🤖 I have created a release *beep* *boop* --- ## [1.87.0-rc.2](v1.86.0...v1.87.0-rc.2) (2026-09-14) ### Features * backend config shadow mode ([#7340](#7340)) ([4898165](4898165)) * bump rudder-go-kit and go modules to Go 1.27.1 ([#7345](#7345)) ([8d95c68](8d95c68)) * **router:** read transformerProxy from transformer features before env ([#7337](#7337)) ([e8f0ea6](e8f0ea6)) ### Bug Fixes * **router:** redact credentials from destination URLs in failure responses ([#7372](#7372)) ([14659bf](14659bf)) * **warehouse:** instrument the clickhouse v2 load path ([#7355](#7355)) ([4d743db](4d743db)) * **warehouse:** pass temporary credentials to the clickhouse v2 s3 copy engine ([#7353](#7353)) ([4d743db](4d743db)) * **warehouse:** retire idle clickhouse v2 connections ([#7352](#7352)) ([4d743db](4d743db)) * **warehouse:** retry a failed clickhouse v2 block ([#7354](#7354)) ([4d743db](4d743db)) ### Miscellaneous * log the candidate error when a backend config shadow sample fails to fetch ([#7383](#7383)) ([eaa9b61](eaa9b61)) * **processor:** assemble side-PU report metrics at end of preprocess stage ([#7346](#7346)) ([4540876](4540876)) * sync release v1.86.0 to main branch ([#7356](#7356)) ([6868c6c](6868c6c)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
This was referenced Sep 14, 2026
Closed
atzoum
pushed a commit
that referenced
this pull request
Sep 14, 2026
🤖 I have created a release *beep* *boop* --- ## [1.87.0-rc.3](v1.86.0...v1.87.0-rc.3) (2026-09-14) ### Features * backend config shadow mode ([#7340](#7340)) ([4898165](4898165)) * bump rudder-go-kit and go modules to Go 1.27.1 ([#7345](#7345)) ([8d95c68](8d95c68)) * **router:** read transformerProxy from transformer features before env ([#7337](#7337)) ([e8f0ea6](e8f0ea6)) ### Bug Fixes * **router:** redact credentials from destination URLs in failure responses ([#7372](#7372)) ([14659bf](14659bf)) * **router:** request fails with unexpected use of stub RoundTripper error ([#7386](#7386)) ([2ff491f](2ff491f)) * **warehouse:** instrument the clickhouse v2 load path ([#7355](#7355)) ([4d743db](4d743db)) * **warehouse:** pass temporary credentials to the clickhouse v2 s3 copy engine ([#7353](#7353)) ([4d743db](4d743db)) * **warehouse:** retire idle clickhouse v2 connections ([#7352](#7352)) ([4d743db](4d743db)) * **warehouse:** retry a failed clickhouse v2 block ([#7354](#7354)) ([4d743db](4d743db)) ### Miscellaneous * log the candidate error when a backend config shadow sample fails to fetch ([#7383](#7383)) ([eaa9b61](eaa9b61)) * **processor:** assemble side-PU report metrics at end of preprocess stage ([#7346](#7346)) ([4540876](4540876)) * sync release v1.86.0 to main branch ([#7356](#7356)) ([6868c6c](6868c6c)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
This was referenced Sep 15, 2026
Merged
atzoum
pushed a commit
that referenced
this pull request
Sep 15, 2026
🤖 I have created a release *beep* *boop* --- ## [1.87.0-rc.4](v1.86.0...v1.87.0-rc.4) (2026-09-15) ### Features * backend config shadow mode ([#7340](#7340)) ([4898165](4898165)) * bump rudder-go-kit and go modules to Go 1.27.1 ([#7345](#7345)) ([8d95c68](8d95c68)) * **router:** read transformerProxy from transformer features before env ([#7337](#7337)) ([e8f0ea6](e8f0ea6)) ### Bug Fixes * **batchrouter:** retry failed async manager initialization ([#7374](#7374)) ([974d383](974d383)) * **router:** redact credentials from destination URLs in failure responses ([#7372](#7372)) ([14659bf](14659bf)) * **router:** request fails with unexpected use of stub RoundTripper error ([#7386](#7386)) ([2ff491f](2ff491f)) * singer-protocol sources filtered destination config for source type cloud instead of cloudSource ([#7389](#7389)) ([f48c997](f48c997)) * **warehouse:** instrument the clickhouse v2 load path ([#7355](#7355)) ([4d743db](4d743db)) * **warehouse:** pass temporary credentials to the clickhouse v2 s3 copy engine ([#7353](#7353)) ([4d743db](4d743db)) * **warehouse:** retire idle clickhouse v2 connections ([#7352](#7352)) ([4d743db](4d743db)) * **warehouse:** retry a failed clickhouse v2 block ([#7354](#7354)) ([4d743db](4d743db)) ### Miscellaneous * log the candidate error when a backend config shadow sample fails to fetch ([#7383](#7383)) ([eaa9b61](eaa9b61)) * **processor:** assemble side-PU report metrics at end of preprocess stage ([#7346](#7346)) ([4540876](4540876)) * sync release v1.86.0 to main branch ([#7356](#7356)) ([6868c6c](6868c6c)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
atzoum
pushed a commit
that referenced
this pull request
Sep 15, 2026
🤖 I have created a release *beep* *boop* --- ## [1.87.0](v1.86.0...v1.87.0) (2026-09-15) ### Features * backend config shadow mode ([#7340](#7340)) ([4898165](4898165)) * bump rudder-go-kit and go modules to Go 1.27.1 ([#7345](#7345)) ([8d95c68](8d95c68)) * **router:** read transformerProxy from transformer features before env ([#7337](#7337)) ([e8f0ea6](e8f0ea6)) ### Bug Fixes * **batchrouter:** retry failed async manager initialization ([#7374](#7374)) ([974d383](974d383)) * **router:** redact credentials from destination URLs in failure responses ([#7372](#7372)) ([14659bf](14659bf)) * **router:** request fails with unexpected use of stub RoundTripper error ([#7386](#7386)) ([2ff491f](2ff491f)) * singer-protocol sources filtered destination config for source type cloud instead of cloudSource ([#7389](#7389)) ([f48c997](f48c997)) * **warehouse:** instrument the clickhouse v2 load path ([#7355](#7355)) ([4d743db](4d743db)) * **warehouse:** pass temporary credentials to the clickhouse v2 s3 copy engine ([#7353](#7353)) ([4d743db](4d743db)) * **warehouse:** retire idle clickhouse v2 connections ([#7352](#7352)) ([4d743db](4d743db)) * **warehouse:** retry a failed clickhouse v2 block ([#7354](#7354)) ([4d743db](4d743db)) ### Miscellaneous * log the candidate error when a backend config shadow sample fails to fetch ([#7383](#7383)) ([eaa9b61](eaa9b61)) * **processor:** assemble side-PU report metrics at end of preprocess stage ([#7346](#7346)) ([4540876](4540876)) * sync release v1.86.0 to main branch ([#7356](#7356)) ([6868c6c](6868c6c)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.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.
Description
A v2 load commits one block per transaction, so every block takes a connection out of the pool. The pool had a size but no lifetime, so a connection the server closed while it sat idle stayed in it.
Why it surfaces as a load failure
BeginTxonly health-checks the connection — a cheap local check that passes.prepareBatchthen does the first real I/O on that dead socket and fails. The driver turns it intodriver.ErrBadConn, and because the connection is already bound to a transaction,database/sqlcannot swap it out the way it does fordb.Query,db.Execanddb.Begin. The error reaches the caller as:That fails the whole table load, however many blocks had already landed. Seen in production after 6,275,000 rows.
The fix
SetConnMaxIdleTimeandSetConnMaxLifetimeon the v2 pool, so a stale connection is retired before a block picks it up.Warehouse.clickhouse.v2.connMaxIdleTime5mWarehouse.clickhouse.v2.connMaxLifetime30mScope
14 lines across
clickhousev2.goanddriver_v2.go. v1 is untouched. No behaviour change beyond connection recycling.Linear Ticket
https://linear.app/rudderstack/issue/INT-7100/crew-workspace-loading-is-taking-lot-of-time
https://linear.app/rudderstack/issue/INT-7107/investigate-connection-time-out
Security