Skip to content

Make server-side AST fuzzer respect KILL, timeout and shutdown - #107640

Merged
Algunenano merged 2 commits into
masterfrom
fuzzer-respect-kill-shutdown
Jun 18, 2026
Merged

Algunenano merged 2 commits into
masterfrom
fuzzer-respect-kill-shutdown

Conversation

@Algunenano

Copy link
Copy Markdown
Member

The server-side AST fuzzer (ast_fuzzer_runs) runs as a query finish callback, after the outer query's pipeline executor has stopped enforcing limits. The fuzzing loop never consulted the outer query status, so it ignored a KILL QUERY, the outer max_execution_time, and server shutdown (which cancels all running queries). The outer query then kept spawning fuzzed queries and lingered in the processlist, which can trigger a false-positive stress test hung check.

Now QueryStatus::checkTimeLimitSoft is checked at the top of each fuzzing iteration. It returns false without throwing on a kill, on the outer query's time limit, or on shutdown (ProcessList::killAllQueries marks every query killed), so the loop stops promptly.

Observed in the stress test hung check of an unrelated PR (#107475):
https://s3.amazonaws.com/clickhouse-test-reports/PRs/107475/6271a231daa9d7adfda7f2c725b71ef672a3feb1/stress_test_arm_asan_ubsan_s3/hung_check.log

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):

...

`executeASTFuzzerQueries` runs as a query finish callback, after the
outer query's pipeline executor has stopped enforcing limits. Its
fuzzing loop never consulted the outer query status, so it ignored a
`KILL QUERY`, the outer `max_execution_time`, and server shutdown
(which cancels all queries). The query then lingered in the
processlist while spawning more fuzzed queries, which can trip the
stress test hung check.

Check `QueryStatus::checkTimeLimitSoft` at the top of each iteration.
It returns false without throwing on a kill, on the outer query's time
limit, and on shutdown (`ProcessList::killAllQueries` marks every query
killed), so the loop stops promptly.

Observed in the stress test hung check on an unrelated PR:
https://s3.amazonaws.com/clickhouse-test-reports/PRs/107475/6271a231daa9d7adfda7f2c725b71ef672a3feb1/stress_test_arm_asan_ubsan_s3/hung_check.log

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [465978d]

Summary: ❌

job_name test_name status info comment
Performance Comparison (arm_release, master_head, 3/6) FAIL Performance dashboard
file_table_function #7::old FAIL query history IGNORED
file_table_function #7::new FAIL query history IGNORED
file_table_function #15::old FAIL query history IGNORED
file_table_function #15::new FAIL query history IGNORED
file_table_function #17::old FAIL query history IGNORED
file_table_function #17::new FAIL query history IGNORED
file_table_function #23::old FAIL query history IGNORED
file_table_function #23::new FAIL query history IGNORED
grace_hash_join #1::old FAIL query history IGNORED
grace_hash_join #1::new FAIL query history IGNORED
26 more test cases not shown
BuzzHouse (amd_msan) ERROR IGNORED

AI Review

Summary

This PR makes executeASTFuzzerQueries poll the outer query state and server shutdown metric before each server-side AST fuzzer iteration. The normal ProcessList-owned path is improved, but a supported no-ProcessList entrypoint still cannot honor the outer deadline, and the new cancellation behavior lacks focused regression coverage.

Findings

⚠️ Majors

  • [src/Interpreters/executeQuery.cpp:2082] executeASTFuzzerQueries still cannot enforce the outer max_execution_time when the fuzzer is triggered by a query without an outer QueryStatus, especially SHOW PROCESSLIST: executeQueryImpl skips inserting ASTShowProcesslistQuery into ProcessList, so context->getProcessListElement returns null and this checkTimeLimitSoft guard is skipped. The new IsServerShuttingDown check covers shutdown for that path, but a large ast_fuzzer_runs loop can still run all iterations after the outer deadline for a supported read-only fuzzer entrypoint. Suggested fix: skip the server-side fuzzer when there is no outer QueryStatus, or provide a cancellable owner/check for no-ProcessList queries before entering the loop.
Tests
  • ⚠️ [src/Interpreters/executeQuery.cpp:2075] The PR changes the cancellation contract of the server-side AST fuzzer, but it does not add a focused regression that would fail if these guards were removed. The existing 03833_server_ast_fuzzer only covers successful fuzzer execution. Please add a stateless or integration test that starts a large ast_fuzzer_runs loop and verifies max_execution_time or KILL QUERY stops it promptly; shutdown coverage can be separate if it is too heavy.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions: fix or explicitly reject no-ProcessList fuzzer execution so the outer deadline is respected for SHOW PROCESSLIST, and add focused timeout/kill regression coverage for the new fuzzer cancellation behavior.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 16, 2026
Comment thread src/Interpreters/executeQuery.cpp Resolved
Some fuzzable queries (e.g. `SHOW PROCESSLIST`) are not inserted into
the `ProcessList`, so the outer `QueryStatus` is null and the
`checkTimeLimitSoft` guard is a no-op. Such a query with a large
`ast_fuzzer_runs` could keep spawning fuzzed queries through server
shutdown.

Check the `IsServerShuttingDown` metric at the top of each iteration.
It is set at the very start of shutdown, before queries are killed, and
does not depend on the outer query having a process-list owner.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread src/Interpreters/executeQuery.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.20% 85.20% +0.00%
Functions 92.30% 92.30% +0.00%
Branches 77.40% 77.50% +0.10%

Changed lines: Changed C/C++ lines covered by tests: 8/12 (66.67%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants