Skip to content

Keep DDL out of the AST fuzzer in 05292_standalone_expression_scalar_subquery_with_join - #123423

Merged
PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/05292-no-ddl-fuzzing
Oct 2, 2026
Merged

PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/05292-no-ddl-fuzzing

Conversation

@groeneai

@groeneai groeneai commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #122795

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

Test-only change, no changelog entry required.

Description

Stress test failed with Cannot start clickhouse-server, the server dying on all 11 start attempts:

Load job 'load table test_l7w8r1o2y0l4_1.t_ttl_replicated__fuzz_1' failed: Code: 393.
DB::Exception: There is no query or query context has expired: While processing (SELECT count()
FROM test_l7w8r1o2y0l4_1.t_probe AS p, merge(REGEXP('.*'), '^t_build$') AS b WHERE p.k != b.k) ...

Failing jobs:
https://github.com/ClickHouse/ClickHouse/actions/runs/36941655753/job/110681526275
https://github.com/ClickHouse/ClickHouse/actions/runs/36954171364/job/110706069151

The table is a fuzzer clone from 05292, which I added in #122795. The stress profile sets
ast_fuzzer_any_query (tests/docker_scripts/stress_tests.lib:211), so the server-side AST fuzzer
replays this file's DDL too. A replay can turn a table in a TTL or CHECK scalar subquery into
merge(), remote() or cluster(). ALTER ... MODIFY TTL accepts that, but the subquery cannot be analysed
while the database loads. The test's own DETACH/ATTACH DATABASE then fails, the final
DROP DATABASE never runs, and the restart after the stress run fails when async_load_databases
is randomized to false.

This pins ast_fuzzer_any_query = 0, the remedy of #121952 for 05234. No CREATE, ALTER,
DETACH or ATTACH of this file is replayed (executeQuery.cpp:3457); its SELECTs still are.

Validation on a debug build with the stress fuzzer profile: 50 runs before the change replayed 2548
DDL statements on the test's tables, 163 of them with a table function in a TTL or CHECK subquery.
50 runs after it replayed 0 DDL and 1566 SELECTs, all OK. Replaying the clone and ALTER from the
CI log reproduces the same error at ATTACH DATABASE, and the restart exits with code 210. 50/50
randomized runs pass.

The ALTER/load asymmetry itself is pre-existing since at least 26.3; its CHECK part belongs to #96886.


Workflow [PR]
Sync PR [sync-upstream/pr/123423]

Version info

  • Merged into: 26.10.1.1299-master (included in 26.10 and later)

…subquery_with_join

Under the stress profile the AST fuzzer replays this test's TTL and CHECK
DDL. It can rewrite a table in the scalar subquery into `merge()` or
`cluster()`; `ALTER ... MODIFY TTL` accepts that, but the subquery cannot be
analysed while the database loads, so the test's own re-attach fails, the
final `DROP DATABASE` never runs and the server restart after the stress run
fails too. Pin `ast_fuzzer_any_query = 0` so only SELECTs are fuzzed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Oct 2, 2026
@groeneai

groeneai commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (2 nits).

# Sev Finding Verdict Evidence / action
1 💡 The fuzzer also rewrites a table into remote()/remoteSecure(), not only merge()/cluster() (src/Common/QueryFuzzer.cpp:3623) AGREE description updated; the second failing job is the remoteSecure() form
2 💡 Other tests keep TTL/CHECK scalar subqueries over plain tables without this setting AGREE, no change none of them re-attaches its own database mid-file, and no CI failure in 30 days

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-8:20261002-054800

@groeneai

groeneai commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Replaying the clone and ALTER ... MODIFY TTL from the CI log makes ATTACH DATABASE fail with 722/393 and a sync-load restart exit with 210, every time.
b Root cause explained? The stress profile fuzzes 05292's DDL; ALTER accepts a table function in a TTL subquery that the database loader cannot analyse, so the re-attach fails and DROP DATABASE is skipped.
c Fix matches root cause? Yes. DDL replay is the only way 05292 persists such a table; the pin removes it at the fuzzer gate (executeQuery.cpp:3457).
d Test intent preserved / new tests added? Yes. Assertions and .reference unchanged; SELECTs are still fuzzed.
e Both directions demonstrated? 50 runs each: before, 2548 DDL replays (163 with a table function); after, 0 DDL and 1566 SELECT replays, 50/50 OK.
f Fix is general across code paths? Every non-SELECT statement of 05292 is gated by the same check.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). 50/50 randomized runs pass.
h Backward compatible? (maintainer-approved exception only) N/A (no product change).
i Invariants and contracts preserved? The test still asserts every original table loads after DETACH/ATTACH DATABASE.

Session id: cron:clickhouse-impl-slot-5:20261002-051700

@clickhouse-gh

clickhouse-gh Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [24f7525]

Summary: ✅


AI Review

Summary

This PR disables all-query AST fuzzing for 05292_standalone_expression_scalar_subquery_with_join so stress runs stop replaying DDL that can persist metadata the database loader cannot analyze on ATTACH DATABASE. The fix is narrowly scoped to the affected test, matches existing patterns in similar metadata-reload tests, and still preserves read-only AST fuzzing for the file's SELECT statements.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 2, 2026
@groeneai
groeneai requested a review from PedroTadim October 2, 2026 06:08
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 2, 2026
@PedroTadim

Copy link
Copy Markdown
Member

@groeneai is this fixing the root cause?

@PedroTadim PedroTadim self-assigned this Oct 2, 2026
@PedroTadim
PedroTadim added this pull request to the merge queue Oct 2, 2026
@PedroTadim

Copy link
Copy Markdown
Member

Have to merge to fix CI

@groeneai

groeneai commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

No, it removes the trigger. The stress profile's AST fuzzer replays 05292's DDL and rewrites t_build/t_probe into merge()/remote()/remoteSecure(); with ast_fuzzer_any_query = 0 that DDL is no longer replayed, which is the only way this test leaves an unloadable __fuzz table behind for the post-stress restart.

The root cause is an older engine gap (26.3 and later): a table function in a TTL or CHECK scalar subquery is accepted by ALTER TABLE ... MODIFY TTL, and by CHECK in both CREATE and ALTER, but the database loader analyses the definition without a query context, fails with Code 393, and the table can no longer be attached after a restart. CREATE already rejects the TTL form.

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 comp-testing Test content only (no production code). groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding 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.

3 participants