Repository navigation
Revert "Fit the insert pipeline and merges into a small server's memory" - #128706
Conversation
…emory" This reverts commit ae6fcab, reversing changes made to 2f0acc8. The PR was merged without an approving review. It changes about 1000 lines of merge selection code (`MergeSelectorApplier`, merge predicates, `SimpleMergeSelector`, `TTLMergeSelector`) together with a new cap on insert squashing that depends on the server memory limit and the number of materialized views, and there is no setting to disable the insert cap. The insert cap makes the block boundaries of a retried insert depend on the memory limit and the set of materialized views at the time of the attempt, which can break insert deduplication on retry. Related: #116083
alexey-milovidov
left a comment
There was a problem hiding this comment.
What was wrong in the logic of this PR? I checked every single item, and everything was correct.
False. The PR went through one of the most thorough reviews you could imagine. |
|
Anyway, if you revert the PR, you are going to introduce a regression: ClickHouse does not work at all on t3a.small machines. |
`Stateless tests (amd_binary, targeted)` and `Integration tests (amd_binary, targeted)` in `MergeQueueCI` stopped at 20 minutes from their start. The integration job hit the limit on broad selections and silently ran only a fraction of them (e.g. 370 of 1618 selected test items for the merge-queue entry of ClickHouse#128706). The merge-queue flaky check keeps its 20-minute limit. Related: ClickHouse#125571
|
I withdraw the review point and the The cap
The previous cap bound only below ~2.27 GiB, so on servers with tens of GiB this is new behavior, not "no-op with several GiB". 1. Retry can lose or duplicate rows in MV targetsAfter the view query, the output goes through
The cap can differ between attempts because the hard limit is dynamic by default ( 2. More and smaller parts in MV targets10 views at 28 GiB gives 2.5x more parts in every target, more with larger 3. No way to turn it offThe constants are hardcoded and the result is 4. Merges of wide tables
5. Async insert with dedup
I'm merging the revert to keep this out of 26.11. Happy to help re-land it in pieces: the merge width estimate on its own, and the insert cap behind a setting, with the view cap not depending on the stream count and a fix for the view block numbering on retry. |
|
Ok, at least item 3 makes sense... |
…ate_adaptive_write_buffer `max_memory_ratio_to_activate_adaptive_write_buffer` was reverted on master (#128706 reverts #116083 "clickbench-small-memory"), so it no longer exists in the binary CI builds. The randomizer still injected `--max_memory_ratio_to_activate_adaptive_write_buffer` into every test's client args, so every test that drew it failed with return code 40 `Code: 552 ... Unrecognized option ... (UNRECOGNIZED_ARGUMENTS)` regardless of content - a systemic storm across the targeted and all flaky-check jobs ("Too many test failures"). Comment the entry out (keep it for re-enable if the setting ever returns). `min_columns_to_activate_adaptive_write_buffer` and `merge_memory_estimate_per_source_part_column` are unaffected (the latter is not randomized). CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=106734&sha=9b5082447401231d07326cb0c3b15e2152dfbdd8&name_0=PR PR: #106734 Co-Authored-By: Claude Opus 4.8 <[email protected]>
Randomize many more server and MergeTree settings in clickhouse-test, and pin or narrow the tests whose observable plan/EXPLAIN/spill/cache/stats output the extra randomization legitimately changes (results unchanged). Output-changing settings that make poor randomization candidates are commented out of the randomizer (kept, so they can be re-enabled); one-off non-bug test failures are pinned to the setting's default in the test itself. Each pin carries a comment explaining which randomized setting it guards against. Rebased onto current master and squashed. The reverted MergeTree setting `max_memory_ratio_to_activate_adaptive_write_buffer` (#128706 reverts #116083) is no longer randomized. PR: #106734 Co-Authored-By: Claude Opus 4.8 <[email protected]>
The Parquet reader keeps a whole pipeline of `input_format_parquet_prefer_block_bytes` blocks in flight: prefetched, decoded and ready to deliver. Measured on the 105-column ClickBench `hits` table, the default 16 MiB preferred block size costs about 290 MiB of live reader memory, so a cap of a 64th of the budget did not help a small server. With the default setting the new cap binds only below about 4.4 GiB of memory limit. This is a part of ClickHouse#116083 reverted in ClickHouse#128706, re-submitted separately. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…by default The squashing stages of an `INSERT` cap `min_insert_block_size_bytes` by the memory limit. The cap was hardcoded as 0.9 / 8 of the limit, could not be disabled, and was too high for a small server: a squashing stage holds several block-sized copies at once. The new setting `insert_squashing_max_memory_ratio` (default 1/16) replaces the hardcoded fraction. The cap depends only on the memory limit and the setting, not on the number of materialized views or insert streams. `0` disables the cap, and `0.1125` gives the previous behavior. This is a part of ClickHouse#116083 reverted in ClickHouse#128706, re-submitted in a reduced form. Co-Authored-By: Claude Opus 5.5 <[email protected]>
cc. @alexey-milovidov Revert #116083. It is not in any release branch yet (merged to master on 2026-10-25), so reverting now keeps it out of 26.11.
Reasons:
MergeSelectorApplier, the merge predicates,SimpleMergeSelector,TTLMergeSelector,PartProperties) and adds a cap on insert squashing in the same change. Changes of this size in merge selection need a review by the MergeTree owners.min_insert_block_size_bytes.max_server_memory_usage(including the dynamic hard limit) and on the number of materialized views and insert streams. Because of that, a retried insert can be split into a different number of blocks than the first attempt. From reading the code (not reproduced yet), this can lead to:use_strict_insert_block_limits = 1, which hashes blocks after squashing.2 * views * streams, so with 10 views it applies below about 71 GiB, and more withparallel_view_processing = 1. This means more and smaller parts, more non-atomic inserts for clients that send many chunks, and more pressure towardsTOO_MANY_PARTSon mid-size servers.merge_memory_estimate_per_source_part_columnnarrows horizontal merges of wide tables on small servers, and the width also moves with the dynamic hard limit, so the part count stays higher.The changes can be re-submitted in smaller pieces (the merge width estimate separately from the insert cap, each behind a setting) and reviewed.
The documentation pages under
docs/reference/settings/that mentionmerge_memory_estimate_per_source_part_columnare autogenerated and will be updated by the documentation autogeneration workflow.Related: #116083
Related: #100389
Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/128706]
Version info
26.11.1.1229-master(included in26.11and later)