Skip to content

Use fewer stateful-prepare insert threads for regular sanitizer runs - #110185

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/sanitizer-insert-threads-stateful-prepare
Aug 30, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/sanitizer-insert-threads-stateful-prepare

Conversation

@groeneai

@groeneai groeneai commented Jul 12, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

The stateful data prepare step runs INSERT INTO test.hits_s3 SELECT * FROM test.hits with max_insert_threads=16. On regular sanitizer Stateless jobs this single INSERT tracks ~24 GiB and pushes ASan RSS to ~42 GiB, which memcg-OOM-kills the server (Server died + OOM in dmesg).

#109954 already reduced this to 4 threads on sanitizer builds, but only for the bugfix-validation path, because build_type is only passed there. On regular runs build_type is None, so is_sanitizer was always False and the INSERT still used 16 threads.

Fix: when build_type is not passed, fall back to Info().job_name to detect the sanitizer, mirroring the existing limit_source pattern in functional_tests.py::run_tests (which already does build_type if build_type is not None else Info().job_name). Same data is loaded, just a smaller peak.

Example failure (amd_asan_ubsan, distributed plan, parallel): peak server MemoryTracking 24.2 GiB at 17:47:14 from the single hits_s3 INSERT; server OOM-killed at 42 GiB anon-rss. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110152&sha=729886a3f8576eae108e6bd09bc29c4922a39212&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29

Version info

  • Merged into: 26.9.1.381 (included in 26.9 and later)

The hits_s3 stateful data prepare INSERT (INSERT INTO test.hits_s3 SELECT
* FROM test.hits) runs with max_insert_threads=16 on regular sanitizer
Stateless jobs, tracking ~24 GiB and pushing ASan RSS to ~42 GiB, which
memcg-OOM-kills the server (Server died + OOM in dmesg).

The prior reduction to 4 threads only applied to bugfix-validation runs
because build_type is only passed there. Fall back to the job name to
detect the sanitizer on the regular path too, mirroring the limit_source
pattern in functional_tests.py::run_tests.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov — follow-up to #109954: that reduced stateful-prepare insert threads to 4 on sanitizer builds, but only on the bugfix-validation path (build_type is only passed there). Regular sanitizer Stateless jobs still used 16 threads, so the hits_s3 INSERT tracked ~24 GiB and OOM-killed the server. This falls back to the job name to detect the sanitizer on the regular path too.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 12, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [742062b]

Summary: ✅


AI Review

Summary

This PR tries to make prepare_stateful_data fall back to Info().job_name so sanitizer stateless jobs keep max_insert_threads=4 even when build_type is absent. On the current base, the regular stateless path already passes the parameter string with the sanitizer name into prepare_stateful_data, so the new fallback is not exercised for the jobs called out in the PR description. I would request changes because the patch no longer alters the behavior it claims to fix.

Findings

⚠️ Majors

  • [ci/jobs/scripts/clickhouse_proc.py:585] The PR’s contract is that regular sanitizer stateless jobs still reach prepare_stateful_data with build_type=None, but the current regular caller already forwards args.options at ci/jobs/functional_tests.py:870-882, and the CI job definitions populate that with strings like amd_asan_ubsan, distributed plan, parallel, amd_tsan, parallel, amd_msan, WasmEdge, ..., and arm_asan_ubsan, azure, parallel (ci/defs/job_configs.py:696, :778, :793, :863). That means the new Info().job_name fallback is dead for the affected CI jobs, so this patch no longer changes the behavior it claims to fix.
  • Suggested fix: point to the remaining caller that still passes None, or retarget/drop the PR if the gap was already closed elsewhere.
Final Verdict
  • Status: ⚠️ Request changes
  • The minimum required action is to show the still-broken caller path this patch changes in current code, or otherwise close/retarget the PR because it is stale.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 12, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — d38e5df

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stress test (amd_debug) / Stream ... for column ... is not found (STID 3190-5d8a) flaky (trunk Variant/Dynamic/JSON subcolumn serialization family; 6 hits / 6 unrelated PRs / 0 master, 30d) a fix task is moved to pending (investigating at full effort; #107562 merged but did not cover this sub-signature — fixing-PR link to follow here)
Stress test (amd_debug) / Cannot start clickhouse-server + Check failed infra (same-run cascade: server failed to start after the above LOGICAL_ERROR aborted it) owned by the same fix task above

This PR touches only ci/jobs/scripts/functional_tests.py (thread-count for the stateful data-prepare INSERT on sanitizer builds); it cannot cause a server-side Variant/Dynamic serialization LOGICAL_ERROR. Confirmed not PR-caused.

Session id: cron:our-pr-ci-monitor:20260713-020000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for Stress 'Stream ... is not found' (STID 3190-5d8a): #110204 — the residual variant_discr-missing case where ALTER MODIFY COLUMN turns a non-dynamic column into Dynamic/JSON on a Wide part, not covered by #107562.

@leshikus leshikus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this is the same pattern as in functional_tests.py::run_tests

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Jul 28, 2026
@groeneai groeneai added the groeneai-origin-unknown PR origin: unclassified (legacy task) label Aug 19, 2026
# just a smaller peak. On regular (non-bugfix-validation) runs build_type
# is not passed, so fall back to the job name to detect the sanitizer,
# mirroring the limit_source pattern in functional_tests.py::run_tests.
sanitizer_source = build_type if build_type is not None else Info().job_name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current regular stateless path already passes a non-None build identifier into prepare_stateful_data: functional_tests.py forwards args.options at ci/jobs/functional_tests.py:870-882, and the CI job definitions populate that with strings like amd_asan_ubsan, distributed plan, parallel / amd_tsan, parallel / amd_msan, WasmEdge, ... (ci/defs/job_configs.py:696, :778, :793, :863). Because of that, the jobs named in the PR description never reach this Info().job_name fallback in current code, so this patch no longer changes the behavior it claims to fix.

If there is still a remaining caller that invokes prepare_stateful_data with build_type=None, could you point to that path? Otherwise this PR looks stale and should probably be dropped or retargeted.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, and the change that made this unreachable is already on this branch.

On master (ca27b5fb05aeef97) prepare_stateful_data has exactly two callers repo-wide, and neither can pass None:

  • ci/jobs/functional_tests.py:1002 passes build_types[0] if is_bugfix_validation else args.options
  • ci/jobs/functional_tests.py:1231 passes bugfix_bt

--options is declared with default="" in parse_args, so args.options is always a string; functional_tests.py:397 already depends on that, calling .split(",") on it unconditionally. The commit that moved the detection to the call site is a9bc526b0 "Propagate build type to prepare_stateful_data for normal sanitizer runs" from #110574 (merged 2026-07-18), and it reached this branch in the 2026-07-28 master merge, so the fallback here is dead code on its own head.

Measured rather than argued: I lifted the thread-count statements verbatim from both trees and drove them over the --options string of every functional-tests job instance master defines (61 instances, 29 carrying a sanitizer token). max_insert_threads is identical on all 61. The only input on which the two versions differ is build_type=None, which no caller produces.

One correction to the retarget option: a caller passing an empty --options would also get 16 threads, and this patch would not change that either, since it tests is not None rather than truthiness. No job passes empty --options (0 of 61), so there is nothing left to retarget to.

So this is superseded by #110574 and can be closed.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 30, 2026
Merged via the queue into ClickHouse:master with commit 4539487 Aug 30, 2026
181 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors groeneai-origin-unknown PR origin: unclassified (legacy task) manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants