Skip to content

chore: sync release v1.86.1 to main branch - #7371

Merged
atzoum merged 5 commits into
masterfrom
sync-release-f1682a3398f29972ff3373e4faf714c27b06659f
Sep 9, 2026
Merged

atzoum merged 5 commits into
masterfrom
sync-release-f1682a3398f29972ff3373e4faf714c27b06659f

Conversation

@rudderstack-github-actions

Copy link
Copy Markdown
Contributor

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

achettyiitr and others added 5 commits September 9, 2026 14:27
# 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

`BeginTx` only health-checks the connection — a cheap local check that
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 reaches the caller as:

```
preparing statement INSERT INTO ...: driver: bad connection
```

That fails the whole table load, however many blocks had already landed.
Seen in production after 6,275,000 rows.

### The fix

`SetConnMaxIdleTime` and `SetConnMaxLifetime` on the v2 pool, so a stale
connection is retired before a block picks it up.

| key | default |
| --- | --- |
| `Warehouse.clickhouse.v2.connMaxIdleTime` | `5m` |
| `Warehouse.clickhouse.v2.connMaxLifetime` | `30m` |

### Scope

14 lines across `clickhousev2.go` and `driver_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

- [ ] The code changed/added as part of this pull request won't create
any security issues with how the software is being used.
# 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:

```go
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.

Co-authored-by: Claude Opus 5 <[email protected]>
…py engine (#7353)

# Description

`ObjectStorageType` reports `S3` whenever `useRudderStorage` is set, so
`UseS3CopyEngineForLoading` engaged and `credentials()` then read
`accessKeyID` / `accessKey` off the destination config — which describes
the customer's bucket, not Rudder's. They came back empty and were
interpolated into the `s3` table function as `''`, which the server
rejects as an access error that says nothing about where the keys should
have come from.

### Rudder storage is not the only destination without keys

| destination shape | holds keys in config? |
| --- | --- |
| rudder storage (`useRudderStorage`) | no — Rudder's bucket, reached
via the SDK credential chain |
| role-based (`iamRoleARN`) | no |
| shared copy user (neither keys nor role) | no — keys live in the
server's env, see `misc.GetObjectStorageConfig` |
| static keys | yes |

All three keyless shapes authenticate through the AWS SDK credential
chain, which the `s3` table function cannot use because it only takes
literals.

### The fix

Mint the literals instead of enumerating which shape the destination is.
`whutils.GetTemporaryS3Cred` already covers every one of them, and
`redshift`, `snowflake` and `deltalake` all build their copy credentials
from it unconditionally for exactly this reason:

```go
case warehouseutils.S3:
	accessKeyID, secretAccessKey, sessionToken, err = ch.TemporaryS3Cred(&ch.Warehouse.Destination)
```

ClickHouse can do the same because the `s3` table function has taken a
session token as its **fourth positional argument since 24.1**
([ClickHouse/ClickHouse#57850](ClickHouse/ClickHouse#57850)):

```
s3(url, access_key_id, secret_access_key, session_token, format, structure, compression_method)
```

So the copy engine stays available to every aws destination rather than
falling back to downloading each load file — which is the larger win,
since that engine is the fastest path we have.

### Compatibility

- The token is **omitted from the statement when there is none**, so
minio and any static-key path send the six arguments they always sent.
Nothing regresses on a server older than 24.1.
- v1 keeps skipping the engine for rudder storage: it has no
temporary-credential path and runs against ClickHouse 21, which predates
the argument entirely.
- The query-log mask (`s3CredentialsRegex`) widens to cover a third
credential argument.

### Behaviour change worth noting

A **static-key** S3 destination now also goes through STS, so it needs
`sts:GetSessionToken` on the IAM user, and the statement carries a
credential that expires after `Warehouse.awsCredsExpiryInS` (1h default)
rather than the customer's long-term secret. That is the same trade
redshift, snowflake and deltalake already make.

### Tests

- Unit: four destination shapes — rudder storage, role, no credentials
at all, static keys — all asserted to reach the same mint call; minio
asserted never to.
- Integration: a new `Load Table round trip` case reaches the same minio
bucket as an **aws** destination, minting from **minio's own STS**, so
the session token the statement carries is one the bucket actually
validates end to end.

## 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.
# 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]>
🤖 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>
@codecov

codecov Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.05109% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.68%. Comparing base (f4dc4d9) to head (f1682a3).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
warehouse/integrations/clickhouse/load_v2.go 88.18% 7 Missing and 6 partials ⚠️
warehouse/integrations/clickhouse/clickhouse.go 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7371      +/-   ##
==========================================
+ Coverage   80.44%   80.68%   +0.24%     
==========================================
  Files         615      619       +4     
  Lines       69132    70464    +1332     
==========================================
+ Hits        55616    56857    +1241     
- Misses      10285    10343      +58     
- Partials     3231     3264      +33     

☔ 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.

@atzoum
atzoum merged commit 4d743db into master Sep 9, 2026
211 of 218 checks passed
@atzoum
atzoum deleted the sync-release-f1682a3398f29972ff3373e4faf714c27b06659f branch September 9, 2026 14:26
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.

4 participants