Repository navigation
Make 02981_insert_select_resize_to_max_insert_threads deterministic under free-memory limiter - #104449
Conversation
… under free-memory limiter The test exercises `EXPLAIN PIPELINE INSERT INTO ... SELECT` with `max_insert_threads=8` and asserts that the resulting pipeline contains exactly 8 sinks. Since ClickHouse#100383 (`Limit max_threads and max_insert_threads based on available free memory`), `max_insert_threads` is trimmed when the server has less than `max_insert_threads_min_free_memory_per_thread` (default 4 GiB) of free memory per requested thread. In `Stateless tests (amd_llvm_coverage_per_test, per_test_coverage, 8/8)` the per-test coverage instrumentation reduces available memory, so the limiter clamps the requested 8 threads to 5–7 and the test fails: ``` - inserting into a remote table from local with concurrency equal to max_insert_threads - 8 + 5 ``` Pass `--max_threads_min_free_memory_per_thread=0` and `--max_insert_threads_min_free_memory_per_thread=0` on every `clickhouse-client` invocation in the test so the requested `max_insert_threads=8` is preserved regardless of concurrent memory pressure. Same fix pattern applied to `02343_aggregation_pipeline.sql` in the original PR. Reproduced locally by injecting `--max_threads_min_free_memory_per_thread=24000000000` `--max_insert_threads_min_free_memory_per_thread=24000000000` into `CLICKHOUSE_CLIENT_OPT`: before the fix the test fails with 4 sinks instead of 8; after the fix it passes 50/50 runs both with and without the injected throttle. CI failure example: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=8eaaf96ca45fffc4f228cc8892660bd20e9f4b99&name_0=NightlyCoverage&name_1=Stateless%20tests%20%28amd_llvm_coverage_per_test%2C%20per_test_coverage%2C%208%2F8%29
|
Pre-PR validation gate (TASK.md Phase 4 Step 9): a) Deterministic repro? Yes. Inject b) Root cause explained? Yes. PR #100383 added a free-memory based limiter to c) Fix matches root cause? Yes. Setting both d) Test intent preserved? Yes. The test's purpose is to verify that the resize stage produces exactly e) Both directions demonstrated? Yes.
f) Fix is general? Test-only fix. The underlying behavior (memory limiter trimming threads) is intentional per #100383 and not a bug. A sibling test Session: |
|
cc @alexey-milovidov — could you review this? Same fix pattern as your |
|
Workflow [PR], commit [1016567] Summary: ✅ AI ReviewSummaryThis PR makes Missing context / blind spots
Final VerdictStatus: ✅ Approve |
|
@groeneai please fix the ci failure in a new PR: Logical error: 'std::exception. Code: 1001, type: std::out_of_range, e.what() = unordered_map::at: key not found (version 26.5.1.465), Stack trace: (STID: 2508-34fb) |
|
@tiandiwonder — STID 2508-34fb (and sibling stack-frame variants 2508-3132, 2508-3307, 2508-3cd3) are the chronic
We've publicly committed to opening our own follow-up fix PR targeting the residual code path. Investigation in progress: identifying which Tracking PR will be opened separately; this PR (#104449) is not blocked by the family bug. |
|
Dear @tiandiwonder, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
@groeneai please merge the PR with latest master and then check ci result. |
|
@tiandiwonder done. Merged latest master into the branch (clean, zero conflicts; master had not touched the test file). New HEAD: |
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 922 line(s), 82 function(s) across 116 file(s) · Details Top files
|
…sert-select-resize Make `02981_insert_select_resize_to_max_insert_threads` deterministic under free-memory limiter
The test exercises
EXPLAIN PIPELINE INSERT INTO ... SELECTwithmax_insert_threads=8and asserts that the resulting pipeline contains exactly 8 sinks. Since #100383 (Limit max_threads and max_insert_threads based on available free memory),max_insert_threadsis trimmed when the server has less thanmax_insert_threads_min_free_memory_per_thread(default 4 GiB) of free memory per requested thread.In
Stateless tests (amd_llvm_coverage_per_test, per_test_coverage, 8/8)the per-test coverage instrumentation reduces available memory, so the limiter clamps the requested 8 threads to 5–7 and the test fails:Pass
--max_threads_min_free_memory_per_thread=0and--max_insert_threads_min_free_memory_per_thread=0on everyclickhouse-clientinvocation in the test so the requestedmax_insert_threads=8is preserved regardless of concurrent memory pressure. Same fix pattern applied to02343_aggregation_pipeline.sqlin the original PR.The test had no master failures before #100383 was merged on 2026-05-01 23:22 UTC; the first failure landed on 2026-05-02 03:55 UTC, ~4 hours later. CIDB shows 7 master hits in the 14-day window since, all on
per_test_coverage. There is noflaky testGitHub issue for it yet.Reproduction (deterministic):
I injected the limiter manually into
CLICKHOUSE_CLIENT_OPTto simulate the per-test-coverage memory pressure:Before the fix the test fails with
4sinks instead of8(the same failure shape as CI):After the fix the test passes 50/50 runs both with and without the injected throttle.
CI failure example: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=8eaaf96ca45fffc4f228cc8892660bd20e9f4b99&name_0=NightlyCoverage&name_1=Stateless%20tests%20%28amd_llvm_coverage_per_test%2C%20per_test_coverage%2C%208%2F8%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Version info
26.7.1.125