Repository navigation
Change max_insert_threads default to auto (number of CPU cores) - #109006
Conversation
Previously `max_insert_threads` defaulted to `0`, which was treated as `1` (no parallel execution) for `INSERT SELECT`. Change its type to `MaxThreads` so the default `0` resolves to `auto` - the number of CPU cores available to the server (the same auto value as `max_threads`). The number of insert threads is still capped at query time by the available free memory via the existing `max_insert_threads_min_free_memory_per_thread` (4 GiB) limiter, and never exceeds `max_threads`. This parallelizes `INSERT SELECT` by default. To restore the previous single-threaded behavior, set `max_insert_threads` to `1` or set the `compatibility` setting to a version below `26.7`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [919df2c] Summary: ✅
AI ReviewSummaryThis PR changes Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block |
… SELECT With the new default `max_insert_threads = auto`, `INSERT SELECT` runs in parallel by default, which changes these tests: - `03622_explain_indexes_distributed_index_analysis`: parallel insert produces a different number of parts, so the distributed index analysis reports a different number of granules per replica. - `03217_primary_index_memory_leak`: parallel insert multiplies the peak memory across insert threads, exceeding the test's `max_memory_usage = '100M'` and raising `MEMORY_LIMIT_EXCEEDED`. Both tests intentionally exercise single-threaded insert behavior, so pin `max_insert_threads = 1` to restore the deterministic single-threaded path; their references are unchanged. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109006&sha=4eecd7967735a331e1968f519c648c6047cceb93&name_0=PR&name_1=Fast%20test Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`max_insert_threads` is now of type `MaxThreads`, so an explicit `max_insert_threads = 0` is stringified as the machine-dependent `auto(N)` in `system.query_log` (`SettingsImpl::dumpToMapColumn` writes `getValueString`, and `SettingFieldMaxThreads::toString` returns `auto(N)` for the auto state). `01275_parallel_mv` and `03403_mv_errors` select `Settings['max_insert_threads']` from `system.query_log` and their references expected the literal `0`, so the rows became non-deterministic `auto(N)` strings (which also reorder under `ORDER BY ALL`). Iterate over `max_insert_threads in [1, 5]` instead of `[0, 5]`. This keeps the non-parallel (`1`) and parallel (`5`) coverage the tests care about, while recording stable values. The previous default (`0`) was already treated as a single thread, so replacing it with an explicit `1` produces identical execution - only the recorded label changes from `0` to `1`, so the references are updated in place with no reordering. The auto default itself is covered by `04492_max_insert_threads_auto_default`. Addresses the review comment on `src/Core/Settings.cpp`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The stateless-test settings randomizer injects an explicit `--max_insert_threads N` (randint(1, 3)) on every run. That marks `max_insert_threads` as changed, so the `SETTINGS compatibility = '26.6'` query in `04492_max_insert_threads_auto_default` can no longer reset the value to its pre-26.7 default of `1` (the `compatibility` mechanism only applies to unchanged settings). The fourth assertion then observed the randomized `2`/`3` instead of `1`, failing every stateless job that runs with randomization (both the parallel jobs and the flaky check). The CI harness confirmed the diagnosis directly: "Passes without randomization. Confirmed: the failure is caused by randomized settings." The test verifies the compile-time default and the `compatibility`-derived value of the very setting the randomizer overrides, so `no-random-settings` is strictly necessary here rather than avoidable. CI report: #109006 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
The sole hard red here — It is the same class @groeneai is allowlisting in #109042, but that PR's regex currently matches only the Everything on this PR's own changes is green; the remaining checks are still in progress. |
|
I have joined nothing to to this table but everything that im trying
leaning
…On Thu, Jul 2, 2026, 9:30 PM clickhouse-gh[bot] ***@***.***> wrote:
***@***.***[bot]* commented on this pull request.
------------------------------
In src/Core/Settings.cpp
<#109006 (comment)>
:
> @@ -269,21 +269,24 @@ Allow multiple threads to process non-joined rows from the right table in parall
This can speed up the non-joined phase when using the `parallel_hash` join algorithm with large tables.
When disabled, non-joined rows are processed by a single thread.
)", 0) \
- DECLARE(UInt64, max_insert_threads, 0, R"(
+ DECLARE(MaxThreads, max_insert_threads, 0, R"(
Changing max_insert_threads to MaxThreads also breaks the Server::Hello
settings packet for mixed-version clients. TCPHandler sends changed
session/profile settings with SettingsWriteFormat::STRINGS_WITH_FLAGS, so
a server-side max_insert_threads = 0 now goes out as auto(N). A 26.6
client still reads this setting as UInt64 in Connection::receiveHello, so
settings.read throws before the session starts. Because
apply_settings_from_server is enabled by default, a rolling upgrade can
lock out older clients as soon as a profile keeps the previously-valid 0
value.
Please preserve the on-wire value 0 for older peers/clients, or avoid
changing the stored setting type here.
—
Reply to this email directly, view it on GitHub
<#109006?email_source=notifications&email_token=CAE37U22XZDXFSGEFR4SAJD5C4LEHA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINRSGIZTGNZTHE2KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#pullrequestreview-4622337394>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/CAE37U2IGHR3OGX6LWCJRDL5C4LEHAVCNFSNUABEKJSXA33TNF2G64TZHM3DAMRUGYZTKOJ3JFZXG5LFHM2DOOBRHAZDIMZXGGQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/CAE37UZ6QAWP7RGGX73QS3D5C4LEHA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINRSGIZTGNZTHE2KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSVGM33PORSXEX3JN5ZQ>
and Android
<https://github.com/notifications/mobile/android/CAE37U3RSHSG7O7XCDCXPMD5C4LEHA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINRSGIZTGNZTHE2KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ>.
Download it today!
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
After the re-merge with
The sole substantive blocker remains the wire-compat design decision at |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Okay. Reviewed. All review comments resolved.
|
CI triage for head 17d1fd6 (merge with
|
|
CI triage update for head 17d1fd6: a third red appeared after the previous triage, also unrelated to
@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109006&sha=17d1fd695c85b4225554cfcfe6375c3672812b6c&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%2C%20old_compatibility%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. The two previously-triaged reds are unchanged: |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 35/35 (100.00%) · Uncovered code |
…marker Extend the benign-Code-241 classifier so it fires on the real PR ClickHouse#109006 log, which two independent gaps caused it to miss, and harden the terminal-cause check. 1. Signature. SERVER_MLE_SIGNATURE required "Received from" and the enum "MEMORY_LIMIT_EXCEEDED" on one line, but a real server-transmitted limit prints the prose "(total) memory limit exceeded" on the "Received from" line and the enum on a separate line, so it matched nothing. Match either the enum or the prose form; the "Received from" prefix keeps it server-origin, so a client-side --max_memory_usage_in_client 241 is still not treated benign. 2. Terminal-block anchor. The block was anchored on the last "Dump of fuzzed AST:" marker, which is printed to stdout. run-fuzzer.sh merges the streams with "> fuzzer.log 2>&1"; stdout is block-buffered when redirected, so the terminal step's dump is flushed at process exit AFTER its own unbuffered stderr exception, and the last dump marker is a trailing re-dump past the evidence. Anchor on the last "Fuzzing step N out of M" marker instead (stderr, causally ordered). No marker (a startup/handshake 241 before any step, or BuzzHouse) falls back to the read tail, as before. 3. Terminal-cause ordering. The terminal block can still hold a server limit the run recovered from earlier followed by a later client/harness 241 -- a recovered query limit then a client-side reconnect/handshake 241 within a step, or the same across a markerless BuzzHouse/startup tail. Treat it as benign only when no client-origin 241 line (a "Code: 241" line with no "Received from" prefix) appears after the last server-origin MLE, so a later client/harness 241 still surfaces while an earlier recovered client 241 does not veto a genuinely terminal server limit. The terminal-step invariant from earlier review rounds is preserved: a swallowed earlier-step query MLE cannot mask a later client 241, both because it sits before the terminal step's "Fuzzing step" marker and because a client 241 after the last server MLE now vetoes the benign classification. Regression tests: a prose-form signature case, a fixture built from the real log's shape (prose MLE + trailing buffered dump), and ordering cases (a later client 241 is not benign in both the marker and no-marker forms; a terminal server limit after an earlier recovered client 241 is benign); the prior invariant tests are kept. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…_memory_usage The test began failing on its INSERT with Code: 241. Query memory limit exceeded: would use 4.66 GiB, maximum: 4.66 GiB (query: insert into t_2354_dist_with_external_aggr select number, toString(number) as s, toFixedString(s, 100) from numbers_mt(5e7);) so it never reached the external aggregation it exists to measure. max_insert_threads changed default from 1 to auto (the number of CPU cores) in ClickHouse#109006. This INSERT carried no SETTINGS clause, so it inherits the profile default and the write side's per-thread buffers now scale with the core count. The 5G budget in this test was measured with single-threaded insert ("5G is just the actual value taken from the logs + delta"), so the peak crosses the 4.66 GiB profile limit from tests/config/users.d/limits.yaml. max_insert_threads_min_free_memory_per_thread does not prevent it: the guard runs and reduced the request from 192 to 134 threads, but its budget is server free memory rather than the query's max_memory_usage, so insert parallelism is never tied to the limit the query is measured against. Pinning max_insert_threads = 1 restores the execution shape the budget was calibrated for. This is the same adaptation ClickHouse#109006 made in the same commit to the tests it identified, for example 03217_primary_index_memory_leak.sql, where max_insert_threads = 1 sits directly beside max_memory_usage = '100M'. This test needed the identical change and did not get it. Measured with the CI binary at this base commit, on a server carrying the CI limits profile: before the fix the test fails in 0.35-0.47 s, with the fix it passes in 10.52 s, and removing only the pin makes it fail again. Peak memory for the INSERT is 2.28 GiB at one thread (48.9% of the budget) versus 4.65 GiB at the default, so the pin leaves real headroom rather than sitting just under the cap. 50 runs with randomization enabled: 50 OK, 0 FAIL. Of the 62 stateless tests combining INSERT ... SELECT with max_memory_usage, 13 already pin max_insert_threads. Across the ClickHouse#109006 merge boundary this test is the only one that regressed, going from 0 failures to 12 across 12 distinct pull requests plus one master run, against 0 failures in the preceding 90 days.
… one bullet Both gaps are in the grouped-restoration path, and both come from a recorded merged bullet covering more pull requests than the restoration is about. **A sibling whose revert still stands.** `#109000` and `#109006` shared a bullet, both were reverted, and only `#109000` has been re-applied. The recorded line still attributes `#109006`, so replaying it advertises a change that is out of the release - the mirror image of the bug this whole pull request is about. `analyze_reverts` now reports `withheld`: the recorded entries whose deletion an uncancelled revert still licenses. The prompt asks for those attributions to be left off the restored bullet, and `verify_edit` rejects a section that attributes any of them, whether they were pasted back or simply never deleted. **A recorded bullet restored as two.** The re-apply check looked only at the bullet of a group's first pull request, so a merged bullet could come back as one bullet per pull request, undoing the merge of skill section 7 and letting each half lose the re-applying link on its own. One recorded bullet now has to come back as one bullet carrying all of its pull requests, and the re-apply link is checked on every one of them rather than on the first. Two tests added, both fail without their fix. The split one asserts that the one-bullet rule catches a split even when both halves carry the re-applying link, so it is not just the re-apply check under another name.
…survivor **`cancelling` was any-target, not every-target.** A revert that undoes something of this release *and* something that shipped earlier was exempt from strict retention on the strength of the first half alone, so its own entry could disappear with the entry it cancels - taking the user-visible half of it (skill section 2, case 5) out of the changelog. The exemption now needs every target to belong to this cycle; one target from an earlier release keeps the revert's entry protected. **The shared-bullet rule ignored the pull requests that never left.** The split check compared the bullets of the restored pull requests only, so with `#109000` and `#109006` off one bullet and only `#109000` restored, re-adding it as a second bullet with the same prose passed everything: no attribution repeats, the category matches, the re-apply link is there. The check now spans the group's `siblings` too, which is what "merge it back into the bullet that survived" means. The duplicate-attribution check moves ahead of the shared-bullet one: pasting the recorded merged bullet beside the survivor trips both, and "you wrote this entry twice" is the more specific diagnosis. Two tests added. Each fails without its fix, and the shared-bullet one asserts that no attribution repeats in its input, so it cannot pass as a restatement of the duplicate check.
With parallel replicas, the initiator constant-folds the `::Point::Geometry` cast and re-serializes the query with `_CAST((0., 0.), 'Geometry')`. The remote replica then fails with `Cannot convert type Tuple(Float64, Float64) to Geometry. Conversion to Variant allowed only for types from this Variant` (`CANNOT_CONVERT_TYPE`), because `Variant` conversion matches member types by name and the folded literal has lost the `Point` custom type name. This is the known parallel-replicas `Variant` conversion bug ClickHouse#74366, not a problem in the test itself, so skip the test under parallel replicas until that bug is fixed. Seen in https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109006&sha=17d1fd695c85b4225554cfcfe6375c3672812b6c&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 on ClickHouse#109006, and failing across master and many PRs (52 failures on 2026-07-20 alone). Co-Authored-By: Claude Fable 5 <[email protected]>
… single-stream Since ClickHouse#109006 made `max_insert_threads` default to the number of cores, the test's `INSERT ... SELECT` writes through several `ReplicatedMergeTreeSink`s; the test was written when it had one. The sink that receives the rows commits `all_0_0_0`, which creates the non-parallel quorum node, and raises the expected `UNKNOWN_STATUS_OF_INSERT` at the `replicated_merge_tree_insert_quorum_fail_0` failpoint. A sink without rows whose `onStart` runs later then finds that node in `checkQuorumPrecondition` and raises `UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE`, which reaches the client first. Pin `max_insert_threads = 1` on that INSERT, as 04912 and 05211 already do. A single sink runs `onStart` before its own commit, so the second error cannot happen. The exact error assertion and the cancel-after-finish path the test covers are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since ClickHouse#109006 (26.8) `max_insert_threads` defaults to auto, so each `INSERT ... SELECT` of these tests writes its 50-100 parts from 8 (amd) or 12 (arm) threads instead of one. A Wide part of the `hits_10m_single` schema is ~475 files; on the IOPS-capped CI disk the parallel writers wait for the write-back of the previous runs (OSIOWaitMicroseconds per INSERT 0.17 s -> 8 s, same OSWriteBytes and FileOpen), so every run is slower than the one before and the three tests became ranks ClickHouse#2, ClickHouse#3 and ClickHouse#5 of the noisiest performance tests on master (ClickHouse#100759), from 0% over the report floors before ClickHouse#109006. Pin the setting to 1, as ClickHouse#109006 documents for restoring the previous behavior. The queries, parts and files written are unchanged; parallel INSERT SELECT stays covered by parallel_insert.xml and insert_parallel.xml. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Change the default value of the
max_insert_threadssetting from1(no parallel execution) toauto.Motivation
max_insert_threadsdefaulted to0, which was treated as1, soINSERT SELECTran single-threaded in open-source ClickHouse, while ClickHouse Cloud already set it to4for larger nodes. It is time for a more reasonable default.What changed
max_insert_threadsis now of typeMaxThreads, so its default0resolves toauto— the number of CPU cores available to the server (the same auto value asmax_threads), and is shown asauto(N)insystem.settings.max_insert_threads_min_free_memory_per_thread(4 GiB) limiter, and never exceedsmax_threads.0(and unset) now mean auto, consistent withmax_threads. Setmax_insert_threads = 1to runINSERT SELECTin a single thread (for example, to preserve the insertion order).SettingsChangesHistoryentry restores the previous default (1) whencompatibilityis set below26.8.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The default value of the
max_insert_threadssetting has been changed from1(no parallelism) toauto, which resolves to the number of CPU cores available to the server (reduced under memory pressure viamax_insert_threads_min_free_memory_per_thread). This parallelizesINSERT SELECTby default and can change the number of parts created by such queries and the order of inserted rows. To restore the previous behavior, setmax_insert_threadsto1, or setcompatibilityto a version below26.8.