Repository navigation
Cap max_threads in the AST fuzzer to avoid server-liveness hangs - #109256
Conversation
The AST fuzzer mutates query settings freely, and a fuzzed max_threads
in the tens of thousands (observed: 65535) makes a single query request
far more pipeline threads than the global thread pool provides
(max_thread_pool_size defaults to 10000). The pool saturates
(CANNOT_SCHEDULE_TASK: no free thread, threads=10000, jobs=10000), which:
- starves the run-fuzzer.sh server-liveness probe: a fresh connection's
SELECT 1 cannot get a thread, so the probe blocks and times out; and
- delays max_execution_time cancellation, because the cancellation-check
machinery itself needs threads it cannot get.
On a loaded amd_debug runner this stretches to minutes. The liveness loop
counts 12 probe timeouts and declares the server hung, the watchdog kills
it, and the job fails with "Lost connection to server" even though the
server never crashed and produced no LOGICAL_ERROR / sanitizer report.
Seen across ~11 unrelated PRs in 30 days (0 on master).
Add a max_threads <max>256</max> constraint alongside the existing
max_execution_time / max_memory_usage caps in the fuzzer users profile.
A fuzzed value above the cap now yields a clean SETTING_CONSTRAINT_VIOLATION
(an expected error the fuzzer already tolerates and continues past) instead
of hanging the server. 256 stays well below the 10000-thread pool so a
single query can't saturate it, while still exercising high parallelism.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260703-044400 |
|
cc @maxknv @PedroTadim — could you review this? It caps |
|
Workflow [PR], commit [aec5d9b] Summary: ❌
AI ReviewSummaryThis PR caps Final VerdictStatus: ✅ Approve |
The stress harness enables the same server-side AST fuzzer (ast_fuzzer_runs=5) via configure_limits in tests/docker_scripts/stress_tests.lib, which writes stress_test_tweaks-users.xml. That profile did not carry the max_threads constraint, so a fuzzed max_threads in the tens of thousands could still saturate the global thread pool in the real stress workload, causing the same server-liveness hang this PR eliminates for the dedicated fuzzer job. Mirror the max_threads <max>256</max> constraint into stress_test_tweaks-users.xml so every ast_fuzzer_runs>0 profile is bounded. The smoke and hung checks in stress.py already force ast_fuzzer_runs=0, so they need no cap. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Re-posting the pre-PR validation gate after 7f03569 (mirror the Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-9:20260703-074200 |
Per reviewer request: 128 still comfortably exceeds any realistic single query thread count and stays far below the 10000-thread global pool, so one fuzzed query cannot saturate it. Applied to both the dedicated fuzzer profile and the mirrored stress-path constraint. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Reposting the pre-PR validation gate after the Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-9:20260703-115000 |
CI finish ledger — bf3bce9Every 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
Session id: cron:our-pr-ci-monitor:20260703-140000 |
|
@groeneai merge with master |
|
@PedroTadim merged master in (aec5d9b). No conflicts; only the two CI-config files differ from master and the max_threads=128 cap is intact in both profiles. |
| the server-liveness probe and delaying query cancellation. Cap it. --> | ||
| <max_threads> | ||
| <max>128</max> | ||
| </max_threads> |
There was a problem hiding this comment.
can you move this to limit-recursion-settings.xml it's shared between all ast fuzzer runs
There was a problem hiding this comment.
Done in follow-up #109755: moved the max_threads 128 cap into limit-recursion-settings.xml (cp'd into users.d by run-fuzzer.sh, clickhouse_proc.py, and stress_runner.sh), and removed the two duplicated copies from query-fuzzer-tweaks-users.xml and stress_tests.lib.
be929a3
…ngs.xml Follow-up to ClickHouse#109256. That PR added a max_threads <max>128</max> constraint in two places (query-fuzzer-tweaks-users.xml and the stress-path stress_test_tweaks-users.xml heredoc in stress_tests.lib). Consolidate it into limit-recursion-settings.xml, which is already cp'd into users.d by every ast_fuzzer_runs entry point (run-fuzzer.sh, clickhouse_proc.py, stress_runner.sh), so a single location covers the dedicated AST fuzzer and the stress test. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…p-max-threads Cap max_threads in the AST fuzzer to avoid server-liveness hangs
…ngs.xml Follow-up to ClickHouse#109256. That PR added a max_threads <max>128</max> constraint in two places (query-fuzzer-tweaks-users.xml and the stress-path stress_test_tweaks-users.xml heredoc in stress_tests.lib). Consolidate it into limit-recursion-settings.xml, which is already cp'd into users.d by every ast_fuzzer_runs entry point (run-fuzzer.sh, clickhouse_proc.py, stress_runner.sh), so a single location covers the dedicated AST fuzzer and the stress test. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
The AST fuzzer mutates query settings freely, and a fuzzed
max_threadsin the tens of thousands (observed: 65535) makes a single query request far more pipeline threads than the global thread pool provides (max_thread_pool_sizedefaults to 10000). The pool saturates (CANNOT_SCHEDULE_TASK: no free thread, threads=10000, jobs=10000), which:run-fuzzer.shserver-liveness probe: a fresh connection'sSELECT 1cannot get a thread, so the probe blocks and times out; andmax_execution_timecancellation, because the cancellation-check machinery itself needs threads it cannot get.On a loaded
amd_debugrunner this stretches to minutes. The liveness loop counts 12 probe timeouts and declares the server hung, the watchdog kills it, and the job fails withLost connection to servereven though the server never crashed and produced noLOGICAL_ERROR/ sanitizer report. Seen across ~11 unrelated PRs in 30 days (0 on master).This adds a
max_threads<max>128</max>constraint alongside the existingmax_execution_time/max_memory_usagecaps in the fuzzer users profile. A fuzzed value above the cap now yields a cleanSETTING_CONSTRAINT_VIOLATION(an expected error the fuzzer already tolerates and continues past) instead of hanging the server. 128 stays well below the 10000-thread pool so a single query cannot saturate it, while still exercising high parallelism. The same constraint is mirrored into the stress-path AST-fuzzer profile (tests/docker_scripts/stress_tests.lib), which also enablesast_fuzzer_runs, so every server-side fuzzer profile gets the cap.Reproduced locally on a debug build (Build ID 6d09f948f426): with the current profile a fuzzed
max_threads=65535query hitsCANNOT_SCHEDULE_TASK: threads=10000, jobs=10000and delaysmax_execution_time=10cancellation to 24s; with the constraint the same query returnsSETTING_CONSTRAINT_VIOLATIONand theSELECT 1liveness probe answers in 0s. A 30-run AST-fuzzer smoke pass against the fixed profile leaves the server alive.Example CI failure (PR #108676): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108676&sha=ca7d8c5328a48a03641468706660084bf1ea9765&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%2C%20old_compatibility%29
Version info
26.7.1.651(included in26.7and later)