Repository navigation
chore: sync release v1.87.1 to main branch - #7409
Merged
achettyiitr merged 2 commits intoSep 18, 2026
Merged
Conversation
# Description
The ClickHouse v2 copy engine loads a table with a single statement that
globs the whole load-file folder:
```go
loadFolder := loadFolderDir + "*.csv.gz"
```
```sql
INSERT INTO "ns"."tracks" (cols)
SELECT * FROM s3('<folder>/*.csv.gz', ..., 'CSV', '<coltypes>', 'gz')
SETTINGS date_time_input_format = 'best_effort',
input_format_csv_arrays_as_nested_csv = 1;
```
ClickHouse downloads, decompresses and parses every file server-side, so
peak memory follows its parse and insert parallelism — not anything
batched client-side (`commitEvery` belongs to
`loadByDownloadingLoadFiles`, the other branch, and is never reached
when the S3 engine is on).
A large enough folder exhausts the instance:
```
code: 241 (total) memory limit exceeded: would use 47.01 GiB
(attempt to allocate chunk of 257.28 MiB), current RSS: 46.84 GiB, maximum: 46.80 GiB
... While executing CSVRowInputFormat: While executing ReadFromObjectStorage
```
Both settings on the statement are parsing semantics, so there was no
lever for this short of resizing the ClickHouse instance.
## Change
Adds seven settings to the copy statement, each resolved per workspace
with a global fallback, matching the existing `disableLoadTableStats` /
`maxLoadDelay` pattern:
| Config key | ClickHouse setting | Default | Reference |
|---|---|---|---|
| `s3Copy.maxThreads` | `max_threads` | `auto(18)` |
[docs](https://clickhouse.com/docs/operations/settings/settings#max_threads)
|
| `s3Copy.maxParsingThreads` | `max_parsing_threads` | `auto(18)` |
[docs](https://clickhouse.com/docs/operations/settings/settings#max_parsing_threads)
|
| `s3Copy.maxInsertThreads` | `max_insert_threads` | `0` (auto; Cloud
sets 4 here) |
[docs](https://clickhouse.com/docs/operations/settings/settings#max_insert_threads)
|
| `s3Copy.maxMemoryUsage` | `max_memory_usage` | `0` — **no per-query
limit** |
[docs](https://clickhouse.com/docs/operations/settings/query-complexity#max_memory_usage)
|
| `s3Copy.minInsertBlockSizeBytes` | `min_insert_block_size_bytes` |
`268402944` (~256 MiB) |
[docs](https://clickhouse.com/docs/operations/settings/settings#min_insert_block_size_bytes)
|
| `s3Copy.minInsertBlockSizeRows` | `min_insert_block_size_rows` |
`1048449` |
[docs](https://clickhouse.com/docs/operations/settings/settings#min_insert_block_size_rows)
|
| `s3Copy.disableParallelParsing` | `input_format_parallel_parsing` |
`1` (enabled) |
[docs](https://clickhouse.com/docs/operations/settings/formats#input_format_parallel_parsing)
|
Resolved as `Warehouse.clickhouse.v2.<workspaceID>.s3Copy.<name>` then
`Warehouse.clickhouse.v2.s3Copy.<name>`. The same links are in the code
beside the settings list.
Defaults above are read from `system.settings` on the affected instance
(ClickHouse Cloud 26.4.1.2359, 18 cores), not just the docs — Cloud has
already set `max_insert_threads = 4` there, and the docs quote
`min_insert_block_size_rows` as `1,048,545` against the server's
`1,048,449`.
### Why these, and what to reach for first
ClickHouse's own [S3 insert tuning
guidance](https://clickhouse.com/docs/integrations/s3/performance) sizes
block size against thread count: `min_insert_block_size_bytes ≈
peak_memory / (3 * max_insert_threads)`. On the affected instance that
is `46.8 GiB / (3 * 4)` ≈ 3.9 GiB, well above the 256 MiB already in
effect — so block size is not what is driving this.
The likelier driver is parse-side parallelism: `max_parsing_threads`
defaults to one per core, `auto(18)` here, and each thread holds a
buffer across a folder of many gzipped files, which is the frame the
failing allocation is inside. `input_format_parallel_parsing = 0` is the
[documented
workaround](ClickHouse/ClickHouse#36823), but
it gives the parallelism up altogether; `max_parsing_threads` bounds it
instead, which matters because the copy path is currently ~7-10x faster
than the insert path it replaced.
Worth noting `max_memory_usage` defaults to `0`, i.e. no per-query
ceiling: the copy was not stopped by its own limit, it grew until it hit
the server-wide budget. Where several workspaces share an instance, one
oversized copy can starve the others rather than just failing itself, so
a per-query cap is useful containment even though it does not reduce
usage.
`max_download_threads` / `max_download_buffer_size` are deliberately
left out: downloads are already capped at 4 threads by default on this
instance, and the stack points at the parse stage, not the fetch.
**Every setting is unset by default, so a deployment that configures
none of them sends a byte-identical statement.** This matters: the S3
copy path is currently ~7-10x faster than the previous insert path in
production, and this change must not regress that by default.
Unset is `-1` rather than `0` because `min_insert_block_size_rows` is
meant to take `0` when paired with `min_insert_block_size_bytes`.
## Test plan
- [x] `go build ./warehouse/...`, `go vet`, `gofmt` clean
- [x] `TestS3CopySettingsV2`: unset default, global keys, per-workspace
override beating global, `0` reaching the statement rather than reading
as unset, parallel parsing disabled by name, the full name mapping
spelled out so a typo in a ClickHouse setting name fails in the test
rather than on the server, and the clause staying a single `settings`
list
- [x] Existing `TestS3CredentialsRegexV2` (credential masking) still
passes against the rebuilt statement
- [x] Integration suite: new `using s3 engine with memory settings` case
in `TestIntegration` loads through the s3 engine with every supported
setting applied, including the two that must be sendable as `0`. Only
the server rejects a bad setting name or a malformed clause, so this is
the layer that proves what the copy engine builds is something
ClickHouse will actually run. (Compiles and vets locally; needs `SLOW=1`
and a running docker daemon, so it runs in CI.)
- [ ] Set `maxParsingThreads` (or `disableParallelParsing`) for the
affected workspace and confirm the load completes without `code: 241`
## Linear Ticket
https://linear.app/rudderstack/issue/INT-7100
## Security
- [x] The code changed/added as part of this pull request won't create
any security issues with how the software is being used.
Every setting value is read through `GetInt64Var` / `GetBoolVar` and
formatted with `%d`, so only integers and a fixed boolean reach the SQL
— config cannot inject arbitrary text into the statement. Credential
masking is unchanged and still covered by `TestS3CredentialsRegexV2`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
🤖 I have created a release *beep* *boop* --- ## [1.87.1](v1.87.0...v1.87.1) (2026-09-18) ### Bug Fixes * bound clickHouse v2 s3 copy memory ([#7407](#7407)) ([ee78070](ee78070)) --- 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>
achettyiitr
requested review from
achettyiitr and
saikumarrs
and removed request for
saikumarrs
September 18, 2026 10:31
achettyiitr
approved these changes
Sep 18, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7409 +/- ##
==========================================
+ Coverage 84.38% 85.29% +0.91%
==========================================
Files 620 620
Lines 62706 63893 +1187
==========================================
+ Hits 52912 54498 +1586
+ Misses 9791 9392 -399
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
saikumarrs
approved these changes
Sep 18, 2026
achettyiitr
deleted the
sync-release-0eb02d7cdb6b5fb9516784b566388af8714bfc19
branch
September 18, 2026 11:23
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
Syncing patch release v1.87.1 to main branch
↓↓ Please review and edit commit overrides before merging ↓↓
BEGIN_COMMIT_OVERRIDE
fix: bound clickHouse v2 s3 copy memory (#7407)
END_COMMIT_OVERRIDE