Skip to content

fix(warehouse): retry a failed clickhouse v2 block - #7354

Merged
achettyiitr merged 1 commit into
release/1.86.xfrom
fix.ch-v2-block-retry
Sep 9, 2026
Merged

achettyiitr merged 1 commit into
release/1.86.xfrom
fix.ch-v2-block-retry

Conversation

@achettyiitr

@achettyiitr achettyiitr commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Description

A single block failure fails the whole table load, and the retry above it restarts the table from scratch. One upload was retried several times in a day, each attempt re-inserting ~11M rows over one transient connection failure.

Why the split into readBlock / sendBlock is required, not cosmetic

The rows come off a csv.Reader shared with the caller. Retrying the previous shape would have pulled the next rows rather than resending the failed ones — skipping a block's worth of data and reporting success. Reading the block before sending it is what makes a retry mean the same thing twice.

Binding still happens per attempt rather than up front, so what is held is the block's raw text and not bound values.

What retries

Only connection-level failures, since the pool can hand over a socket the server closed while it sat idle:

errors.Is(err, driver.ErrBadConn) ||
	errors.Is(err, io.EOF) ||
	errors.Is(err, syscall.EPIPE) ||
	errors.Is(err, syscall.ECONNRESET)
// plus *net.OpError

Anything the server actually rejected is deterministic and returns through backoff.Permanent. Bounded by Warehouse.clickhouse.v2.blockRetries, default 3, 0 disables.

Duplicate rows on a retry

The nastiest case is a send that reached the server but whose ack was lost. We resend a byte-identical block, so ClickHouse's insert deduplication covers it — but only on replicated tables:

setting value applies to
replicated_deduplication_window 10000 Replicated / SharedMergeTree — covered
replicated_deduplication_window_seconds 3600 as above
non_replicated_deduplication_window 0 plain MergeTree — not covered

Values read from a ClickHouse Cloud 26.4 service. Self-hosted non-replicated deployments do not get this safety net.

Memory

Holding the block makes commitEvery a memory knob as well as a batching one — roughly commitEvery × row size resident per concurrent load. At the current default of 1000000 that is substantial on a wide table, and worth lowering to the 100k–250k range on rollout.

Linear Ticket

https://linear.app/rudderstack/issue/INT-7100/crew-workspace-loading-is-taking-lot-of-time

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@codecov

codecov Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.27273% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.97%. Comparing base (3a1407c) to head (81788fa).
⚠️ Report is 1 commits behind head on release/1.86.x.

Files with missing lines Patch % Lines
warehouse/integrations/clickhouse/load_v2.go 76.74% 6 Missing and 4 partials ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           release/1.86.x    #7354      +/-   ##
==================================================
+ Coverage           79.89%   79.97%   +0.07%     
==================================================
  Files                 615      615              
  Lines               69136    69166      +30     
==================================================
+ Hits                55239    55318      +79     
+ Misses              10650    10620      -30     
+ Partials             3247     3228      -19     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@achettyiitr
achettyiitr force-pushed the fix.ch-v2-block-retry branch 2 times, most recently from c8828f8 to 225b559 Compare September 9, 2026 09:15
A single block failure fails the whole table load, and the retry above it
restarts the table from scratch — one upload retried several times today,
each attempt re-inserting ~11M rows over one transient failure.

insertBlock now reads the block before sending it. That is the part that
makes a retry correct: the rows come off a csv.Reader shared with the
caller, so retrying the previous shape would have pulled the *next* rows
rather than resending the failed ones, skipping a block's worth of data
and reporting success.

Only connection-level failures retry — driver.ErrBadConn, EOF, EPIPE,
ECONNRESET, net.OpError. Anything the server rejected is deterministic and
returns through backoff.Permanent. Bounded by maxRetriesPerBlock, default
3, zero disables. The name says how many attempts one block gets rather
than reading as a switch that blocks retrying.

The policy lives in withBlockRetries rather than inline, so it can be
exercised without a server: the tests cover how many attempts each class of
failure buys, that a rejected block is sent exactly once, that the budget
is finite and surfaces the last failure, and that the driver's wrapped
errors are still recognised — a miss there would turn every transient
failure back into a failed load.

The held block makes commitEvery a memory knob as well as a batching one,
so raw records are kept and binding happens per attempt rather than
holding bound values for the lifetime of the block.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4
@achettyiitr
achettyiitr force-pushed the fix.ch-v2-block-retry branch from 225b559 to 81788fa Compare September 9, 2026 09:35
@achettyiitr
achettyiitr merged commit 72390f6 into release/1.86.x Sep 9, 2026
72 checks passed
@achettyiitr
achettyiitr deleted the fix.ch-v2-block-retry branch September 9, 2026 10:07
achettyiitr added a commit that referenced this pull request Sep 9, 2026
# Description

> Stacked on #7354 — review that one first; this PR's diff is only the
instrumentation.

The v2 loader carried a `stats` handle and never used it, so the whole
path was unobserved where v1 emitted seven measurements. A destination
moving to v2 lost every load metric it had. This restores them rather
than adding anything new.

### Metrics

| metric | v1 counterpart |
| --- | --- |
| `warehouse.clickhouse.numRowsLoadFile` | same name |
| `warehouse.clickhouse.downloadLoadFilesTime` | same name |
| `warehouse.clickhouse.loadTableTime` | same name |
| `warehouse.clickhouse.commitTime` | same name, same meaning |
| `warehouse.clickhouse.blockReadTime` | none |
| `warehouse.clickhouse.blockPrepareTime` | none |
| `warehouse.clickhouse.blockBindTime` | none |
| `warehouse.clickhouse.blockSize` | none |
| `warehouse.clickhouse.blocks` | none |
| `warehouse.clickhouse.blockRetries` | none |

The whole set reuses v1's tag set, so a destination stays comparable
across the migration on one dashboard. The block-level metrics have no
v1 counterpart because v1 commits a table once and v2 commits every
`commitEvery` rows.

### Why a block is timed in four parts

Each part is bounded by something different:

- `blockReadTime` — CSV parse, client CPU
- `blockPrepareTime` — a round trip
- `blockBindTime` — `bindValue` per cell plus the driver's append,
client CPU only, because `ExecContext` appends to a client-side batch
and sends nothing
- `commitTime` — the single wire write, since the driver's `Commit` is
`batch.Send`

Timed together they cannot tell a saturated server from a saturated
loader. That ratio is the thing worth knowing before spending
concurrency or moving `commitEvery`, both of which are open questions on
this path.

## Linear Ticket


https://linear.app/rudderstack/issue/INT-7100/crew-workspace-loading-is-taking-lot-of-time

## Security

- [ ] The code changed/added as part of this pull request won't create
any security issues with how the software is being used.

Co-authored-by: Claude Opus 5 <[email protected]>
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>
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
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
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants