Repository navigation
Do not run the server-side AST fuzzer on the stress harness's own queries - #113248
alexey-milovidov wants to merge 24 commits into
Conversation
…imeout The fail-close verification in `install_thread_pool_fault_injection` ran a single `clickhouse client` query with `--receive_timeout=15`. Under `THREAD_FUZZER_*` injection the server can be too sluggish to answer even a trivial `system.server_settings` query within 15 seconds right after `SYSTEM RELOAD CONFIG`, so the client exited with `TIMEOUT_EXCEEDED` and the whole stress run aborted with 'Test script failed' before running any tests. Seen in https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109496&sha=cdcd7ba5f5e3f77ab23cf617534b6bb30668907e&name_0=PR&name_1=Stress%20test%20%28arm_release%29 on #109496. Retry the verification query up to 5 times, keeping the fail-close semantics: persistent failure or a zero probability still aborts the run. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [1daee26] AI ReviewSummaryThis PR propagates Final Verdict✅ No blocking or major issues found in the current diff. |
…jection-verify-retry
The stress profile enables the server-side AST fuzzer for the `default` user with `ast_fuzzer_runs=5` and `ast_fuzzer_any_query=true`, and that also applies to the maintenance queries the harness itself runs. The fuzzer runs as a query-finish callback, so the connection thread executes the five mutated follow-up queries before the response completes. In https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113224&sha=297082adba654b8bafac191c6c61b5023bcc76ef&name_0=PR&name_1=Stress%20test%20%28arm_release%29 (#113224) the verification query of `install_thread_pool_fault_injection` read its 439 rows in 67 ms and the handler then returned after 16.3 s: executeQuery: Read 439 rows, 131.72 KiB in 0.067 sec. ASTFuzzer: Fuzzed query: SELECT value FROM system.server_settings WHERE name = ... ... TCPHandler: Processed in 16.274 sec. which is past the client's `--receive_timeout=15`, so the client exited with `TIMEOUT_EXCEEDED` (code 159) and the whole job failed with "Test script failed" before a single test ran. The server was not slow; the retry added in the previous commit only re-rolls the same dice. All five queries the fuzzer fired on in that run were the harness's own: the `SYSTEM RELOAD CONFIG` and the verification query of `stress.py` (11.3 s and 16.3 s), the two `SELECT 1` readiness probes and the `SYSTEM STOP DISTRIBUTED SENDS` of `stress_tests.lib`. No test query was fuzzed, because `clickhouse-test` runs are already started with `ast_fuzzer_runs=0`. Pin `ast_fuzzer_runs=0` on the harness's queries, which is what `clickhouse-test` does for its infrastructure queries and what `stress.py` already did for the smoke check and the hung check. An explicit value on the command line is marked `changed` even though it equals the default, so the client sends it and it overrides the profile. Besides the timeouts this also stops two things that `ast_fuzzer_any_query` made possible: a fuzzed `DETACH DATABASE` / `KILL QUERY` from `prepare_for_hung_check` or a fuzzed `SYSTEM STOP DISTRIBUTED SENDS` during shutdown running some other statement, and fuzzed copies of a `system.processes` query showing up in the very processlist the hung check is about to inspect. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The previous commit stopped at `stress.py` and `stress_tests.lib`, so the invariant
"the harness does not fuzz its own queries" was not visible in the entrypoints.
Thread `NO_AST_FUZZER` through every server query of `stress_runner.sh`,
`upgrade_runner.sh` and the `create_tpcds.sh` / `create_tpch.sh` helpers as well.
The fuzzer profile is installed by `configure_limits`, not by `configure` (only
`stress_runner.sh` calls it, after the dataset setup), so today those queries are not
fuzzed yet - but nothing in the scripts says so, and moving `configure_limits` earlier
would silently reintroduce the failure mode. The comment in `stress_tests.lib` is
corrected accordingly.
`NO_AST_FUZZER` is now exported, so the `create_*.sh` helpers inherit it; they read it
as `${NO_AST_FUZZER:-}` because `clickhouse_proc.py` also runs them outside the stress
harness.
`install_packages` re-derives the option from the installed binary: `ast_fuzzer_runs`
exists only since 26.2, and the upgrade check installs the previous release, whose
client would reject an unknown command-line option and fail every harness query. The
probe only ever removes the option when the client explicitly reports the setting as
absent, so a failing probe cannot silently re-enable fuzzing of our own queries.
…_replication`
The `stop_log_exports` wrappers in `clickhouse_proc.py` and
`sqlstorm_test.py` ran a plain `clickhouse-client --query "SYSTEM FLUSH
LOGS"` before calling `setup_log_cluster.sh --stop-log-replication`,
outside the `NO_AST_FUZZER` plumbing. Move the flush into
`stop_logs_replication` so the whole log-export lifecycle inherits the
script's existing `${NO_AST_FUZZER:-}` guard and the "the harness's own
queries are not fuzzed" contract is covered in one place.
Co-Authored-By: Claude Fable 5 <[email protected]>
…jection-verify-retry
The `TTLDropMerge` in Case 2 produces an empty part, and the cleanup thread removes empty parts in the background (the `remove_empty_parts` MergeTree setting is enabled by default). When that removal wins the race against the test's `SELECT projections FROM system.parts WHERE ... active` check, the query returns zero rows instead of the expected `[]` line. Set `remove_empty_parts = 0` on the Case 2 table so the empty part deterministically stays active for the check. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113248&sha=0f4ecdf5bcb488588e9d664687d1b482d67d62f9&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20WasmEdge%2C%20parallel%2C%201%2F3%29 PR: ClickHouse#113248 Co-Authored-By: Claude Fable 5 <[email protected]>
…cluster.sh`
The dedicated AST fuzzer job installs `query-fuzzer-tweaks-users.xml`
(`ast_fuzzer_runs=5`, `ast_fuzzer_any_query=true`) in `run-fuzzer.sh` and then
calls `clickhouse_proc.py logs_export_start` without exporting `NO_AST_FUZZER`,
so the local-server queries of this shared helper (`SYSTEM FLUSH LOGS`, the
`BUILD_TYPE` probe, `SHOW TABLES FROM system`, `SHOW CREATE TABLE`) were still
running under the fuzzer profile there. Derive the opt-out centrally in the
helper instead of relying on every caller: `NO_AST_FUZZER=${NO_AST_FUZZER-"--ast_fuzzer_runs=0"}`.
Plain `-` (not `:-`) preserves the deliberate empty opt-out that
`install_packages` sets for a client that predates the `ast_fuzzer_runs`
setting and would reject the unknown option.
Co-Authored-By: Claude Fable 5 <[email protected]>
…jection-verify-retry
Moving the flush into `stop_logs_replication` also turned it from a required step into a warning-only one, so `stop_log_exports` would report success while silently dropping the final buffered system-log rows. Drop the `|| echo WARNING` so the script's `set -e` propagates the failure to the callers, as it did when they ran the flush themselves, while keeping the query under the `NO_AST_FUZZER` guard. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…jection-verify-retry
Conflict in `ci/jobs/scripts/stress/stress.py`: master's `6fe5a48b7b2a`
("Fix stress test failures due to internal queries was fuzzed") landed the same
root-cause fix for `make_query_command`, hardcoding `--ast_fuzzer_runs=0` inline
(and leaving a stray trailing comma that turns the `-> str` return value into a
tuple). Kept this branch's `{NO_AST_FUZZER}`, which is the single place the
option is defined and documented in this script and is what every other query
here already uses.
The runners export `NO_AST_FUZZER`, and `install_packages` deliberately sets it to an empty string for a client that predates the `ast_fuzzer_runs` setting and would reject the unknown command-line option. The upgrade check runs `stress.py` with exactly such a previous-release client (`upgrade_runner.sh` installs `previous_release_package_folder`, then invokes `stress`), so hardcoding the option here would turn every query this script runs into a hard failure once the previous release predates 26.2. Read the variable with a default so the empty opt-out is honoured, and keep the `argv`-form call sites free of an empty argument. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Merged Two notes on that master commit, both handled here:
Also addressed the AI Review Major: the final |
The dedicated AST fuzzer job installs `query-fuzzer-tweaks-users.xml` (`ast_fuzzer_runs=5`, `ast_fuzzer_any_query=true`) and then issues its own plain `clickhouse-client` probes: the readiness loops, the `IS_ASAN` build-options query, the gdb-attach connectivity check, the restart liveness check, the post-run liveness probe loop, and the `stop_server` / `SHOW PROCESSLIST` diagnostics. Each of those triggered five mutated follow-up queries in the connection thread, which can burn the probe's `receive_timeout` or execute a mutated statement before fuzzing starts. Export `NO_AST_FUZZER="--ast_fuzzer_runs=0"` in `run-fuzzer.sh` and thread it through every harness-owned query, mirroring `stress_tests.lib`. The actual fuzzer client invocation deliberately does not use it. This job always runs the freshly built binary, so the pre-26.2 client opt-out of `install_packages` does not apply here. Co-Authored-By: Claude Fable 5 <[email protected]>
…jection-verify-retry
…jection-verify-retry
…jection-verify-retry # Conflicts: # ci/jobs/scripts/functional_tests/setup_log_cluster.sh # ci/jobs/scripts/stress/stress.py
…jection-verify-retry
…jection-verify-retry
|
🕵 Closing as already integrated: the current PR head |
…ness's own queries After a clean fuzz run (`Fuzzer exit code is 143`), the post-fuzz liveness probe `clickhouse-client --handshake_timeout_ms=30000 --receive_timeout=5 --query 'SELECT 1'` sometimes never returns. status.tsv is then never written, praktika kills the job at its 18000 s timeout before any artifact is uploaded, and the job reports a bare ERROR with no server log. Five such runs in 45 days: PR ClickHouse#112304 (2026-08-18), PR ClickHouse#98670 (2026-08-19), PR ClickHouse#115530 (2026-08-20), true master 9816d0a `AST fuzzer (amd_release, oracle)` (2026-09-24) and PR ClickHouse#119237 `AST fuzzer (amd_debug, targeted, old_compatibility)` (2026-09-25). Only the last one printed the `1`. Two harness defects make the probe unbounded. (a) The probe is itself fuzzed on the server. query-fuzzer-tweaks-users.xml sets ast_fuzzer_runs=5 and ast_fuzzer_any_query=true on the `default` profile, and no harness-owned client call opted out. The server runs the mutated copies in a query-finish callback, and TCPHandler calls io.onFinish() after sending the data and before EndOfStream, so a fuzzed follow-up that does not finish holds the reply open after the `1` was printed. The same pin was part of ClickHouse#113248, which was closed as already integrated, but its run-fuzzer.sh half never reached master. The stress harness (ClickHouse#114127), the log export (ClickHouse#117996) and tests/clickhouse-test already pin it. (b) --receive_timeout does not bound the probe either. On a receive timeout ClientBase::receiveResult only records TIMEOUT_EXCEEDED and cancels the query; from then on it polls the connection until the server sends a packet, with no bound. A server whose connection thread never gets back to the socket holds the probe forever, which is what the four runs that printed nothing show. Pin --ast_fuzzer_runs=0 on every harness-owned client call through one variable; the fuzzer's own client stays unpinned. Run the two post-fuzz probes (the restart liveness check and the probe loop) under `timeout --signal TERM --kill-after=10 60`. A probe killed by timeout (rc 124, or 137 after the kill) is counted like the client's own "Timeout exceeded while", so a server that stops answering reaches the existing "treating server as hung" verdict after 12 retries (about 14 minutes) and the job keeps its logs. 60 s covers the probe's own worst case (30 s handshake, 5 s receive timeout, the cancel round trip) with room for a slow sanitizer server. The fallback branch now prints the probe's exit code instead of the last grep's. The pre-fuzz probes are not wrapped: the check after attaching gdb waits for gdb to load debug info on purpose, and the server is fresh there. One server-side hang the fuzzer produces, a self-deadlock when one query builds two system.stack_trace sources, is fixed separately in ClickHouse#120216. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
The stress test aborts with
Test script failedbefore running a single test:The fail-close verification in
install_thread_pool_fault_injection(added in #104782) ran a singleclickhouse clientquery with--receive_timeout=15and no retry, so one slow answer killed the whole job. The first commit retries it, mirroringcall_with_retry, keeping the fail-close semantics: persistent failure or a zero probability still aborts the run.Retrying alone is not enough, because the server is not slow. The stress profile (
stress_tests.lib) enables the server-side AST fuzzer for thedefaultuser withast_fuzzer_runs=5andast_fuzzer_any_query=true, and that also applies to the maintenance queries of the harness itself. The fuzzer runs as a query-finish callback, so the connection thread executes the five mutated follow-up queries before the response completes. In Stress test (arm_release) on #113224 (#113224) the verification query read its 439 rows in 67 ms and the handler returned after 16.3 s, past the client's 15-secondreceive_timeout:Every one of the five queries the fuzzer fired on in that run was the harness's own: the
SYSTEM RELOAD CONFIGand the verification query ofstress.py(11.3 s and 16.3 s in the connection thread), the twoSELECT 1readiness probes and theSYSTEM STOP DISTRIBUTED SENDSofstress_tests.lib. No test query was fuzzed, becauseclickhouse-testruns are already started withast_fuzzer_runs=0.The second commit pins
ast_fuzzer_runs=0on the harness's own queries, instress.pyand instress_tests.lib. That is whatclickhouse-testalready does for its infrastructure queries (clickhouse_execute_http) and whatstress.pyalready did for the smoke check and the hung check. An explicit value on the command line is markedchangedeven though it equals the default, so the client sends it and it overrides the profile.Besides the timeouts this also stops two hazards that
ast_fuzzer_any_querymade possible:DETACH DATABASE/KILL QUERYfromprepare_for_hung_check, or a fuzzedSYSTEM STOP DISTRIBUTED SENDSduring shutdown, running some other statement.system.processesquery showing up in the very processlist the hung check is about to inspect.A fuzzed readiness probe can also burn most of the 30-second
receive_timeoutofstart_server, which reportsCannot start clickhouse-serverfor a server that is up.Related: #109496
Related: #113224
Related: #104782