Repository navigation
Stop stateless tests from stranding metadata that names a dropped named collection - #118504
Conversation
…d named collection
Under the Stress test a table can survive its own `DROP TABLE` while the test's
`DROP NAMED COLLECTION` still runs. The next server start then cannot load the
leftover metadata:
Code: 722 Waited job failed: Code: 695 Load job 'load table test_7.test_s3_base_nc'
failed: Code: 669 There is no named collection `nc_04626_s3_base_setting_test_7`:
Cannot attach table `test_7`.`test_s3_base_nc` from metadata file
store/8bc/.../test_s3_base_nc.sql (NAMED_COLLECTION_DOESNT_EXIST)
-> server process is not running after 11 start attempts
With `async_load_databases = 0`, which `tests/docker_scripts/stress_runner.sh` sets
with probability 1/2, that failure aborts the whole server rather than just the one
table, and the entire Stress exercise for that run produces nothing: no crash
detection, no sanitizer report, no hung check. CIDB records only
`Cannot start clickhouse-server` and `Check failed`.
Four links, all three of the first ones observed in that order in the server log of
the most recent occurrence:
L1 `ignore_drop_queries_probability = 0.2` (`ci/jobs/scripts/stress/stress.py`)
makes `InterpreterDropQuery` replace a client `DROP TABLE` with
`TRUNCATE TABLE` when the engine does not store data on disk, and ignore it
outright when it does. An engine that implements `truncate` (`S3`) or takes
the ignore branch (`Distributed`) therefore leaves the table in place and
still reports rc 0, so an exit-code-gated teardown proceeds. An engine
implementing neither (`URL`, `PostgreSQL` and `S3Queue` inherit the throwing
`IStorage::truncate`) gives the client `Code: 48` instead and the teardown
stops there.
L2 `ast_fuzzer_runs = 5` with `ast_fuzzer_any_query = true`
(`tests/docker_scripts/stress_tests.lib`, applied by both the Stress test and
the Upgrade check) lets the server-side AST fuzzer replay table DDL. The two
observed mutations are a `DETACH TABLE`, which keeps the metadata file, and a
`__fuzz_N` clone of a `CREATE TABLE`, which inherits the collection reference.
L3 `InterpreterDropNamedCollectionQuery` filters dependents through
`DatabaseCatalog::isTableExist`, false for a detached table, so the dependency
guard passes and the edge is removed. The collection drop succeeds.
L4 the `ATTACH` at the next start throws `NAMED_COLLECTION_DOESNT_EXIST` and
`DatabaseOrdinary` rethrows it.
L1 and L2 are deliberate CI fault injections and L3/L4 are server-side, so the fix
belongs in the tests: pin `ast_fuzzer_any_query = 0` on the client invocations that
issue table DDL for the collection-backed table. That closes both observed strand
shapes, including the clone path, and it restores the setting's own default
(`src/Core/Settings.cpp` declares it `false`) for exactly those statements rather
than switching a feature off. `SELECT` and `SHOW CREATE` stay fuzzed, and
`isReadOnlyQuery` in `executeQuery.cpp` admits them whichever value the setting
has. The merged in-tree precedent for this class is
`03822_named_collection_drop_dependency_check.sh`.
Blast radius, CIDB, `test_name = 'Cannot start clickhouse-server'` with
`NAMED_COLLECTION_DOESNT_EXIST` in the context. Over 30 days: 14 rows, 13 distinct
pull requests (ClickHouse#113903 hit twice), 0 with `pull_request_number = 0`, every one a
`Stress test (*)` flavour, spread over 5 tests. The four changed here carry 13 of
those rows:
04320_url_engine_dispatch_partition_and_format_named_collection.sh 6 08-08..08-17
04626_s3_base_setting_named_collection.sh 3 09-05..09-06
04512_remote_missing_named_collection.sh 3 08-15..08-19
04327_s3queue_server_credentials.sh 1 08-14
The 14th belongs to `03822`, which is already pinned; its single hit predates its
pins and it has had none since.
The 30-day window is what shows no master hits, and that is a property of the window
rather than of the defect. Widening the same signature query gives 19 rows at 40 days
and 20 at 45, and the two extra rows both satisfy the full true-master predicate
(`pull_request_number = 0` with `head_ref = 'master'`), both stranding
`04320_url_engine_dispatch_partition_and_format_..._n`:
2026-08-07 15:13:26 Stress test (arm_msan)
2026-07-31 10:53:22 Stress test (arm_tsan)
So this is not confined to pull requests: it has already destroyed two master Stress
runs.
The carrier list is mechanical rather than a reading of a sample. A candidate is a
stateless test that creates and drops a named collection SQL-side and persists an
engine definition naming it, which means `CREATE TABLE`, `CREATE OR REPLACE TABLE`
or a full-definition `ATTACH TABLE`: the last is an `ASTCreateQuery`, writes the
same metadata file and is cloned the same way, so scanning for `CREATE TABLE` alone
misses it. Three candidates are deliberately left unpinned:
- `04070_url_base_setting.sh` and `04546_postgresql_engine_settings.sql`, because
`URL` and `PostgreSQL` implement neither `truncate` nor `storesDataOnDisk`, so
L1's only reachable branch for them raises `Code: 48`, and in both files that
aborts the statement stream before the collection drop. The collection outlives
the table, which is the safe direction.
- `04891_nats_credential_file_path_restriction.sql`, whose metadata-writing
statement is a full-definition `ATTACH` carrying an explicit UUID. In an
`Atomic` database a clone either collides with the live table's UUID or is
rejected by `InterpreterCreateQuery`, and an `attach`-flag-dropped mutant fails
NATS strict startup before committing metadata, so no mutant can persist an
engine definition of its own. The lane is `Atomic`: neither `stress.py` nor
`stress_runner.sh` passes `--db-engine`.
…and a collection reference Same defect class and same one-line fix as the previous commit, on the two carriers the census finds that have no CIDB occurrence yet. They are kept separate so this commit can be dropped whole if a reviewer prefers to land only the proven ones. Both use the `Remote` engine, so they are on the mechanism rather than on a resemblance: `Remote` is `StorageDistributed`, which implements `truncate` and whose `storesDataOnDisk` is true once it has a data volume. Whichever branch L1 takes, the injected `DROP TABLE` therefore returns rc 0 with the table still present, which is the same silent survival that produced the three recorded occurrences of `04512_remote_missing_named_collection.sh`, also a `Remote` carrier. `04318_remote_storage_engine_access.sh` has a second reason: it asserts that `DROP NAMED COLLECTION` is refused while the table exists, by grepping for `NAMED_COLLECTION_IS_USED`. That assertion needs the table attached, so a fuzzed `DETACH` changes the test's own output as well as stranding the metadata. Only the collection-backed table is pinned; the sibling tables in that file carry literal engine arguments and cannot reference a collection.
Internal second-model review
💡 The pin comments were rewritten to one invariant per site after this review; the mechanism and the 💡 The three unpinned candidates ( 💡 |
|
Workflow [PR], commit [e71a2e2] Summary: ✅ AI ReviewSummaryThis PR narrows the server-side AST fuzzer only around the non-read-only table DDL that can strand metadata referencing a dropped named collection in six stateless tests. I reviewed the current diff, the touched tests, and the prior PR discussion, and I did not find a remaining correctness gap in the patched coverage. Final Verdict✅ No findings. |
|
cc @azat, could you review this? With the stress harness arming |
|
cc @qoega |
|
That looks as not a real fix. If we can't start server after some sql queries we should fix it and not just mute the test |
|
You are right, and the product defect is bigger than the CI symptom: reaching it needs no fuzzer at all. Four ordinary statements on master ( CREATE NAMED COLLECTION nc_probe AS url = 'http://127.0.0.1:1/none', format = 'TSV';
CREATE TABLE t_probe (n UInt32) ENGINE = URL(nc_probe);
DETACH TABLE t_probe;
DROP NAMED COLLECTION nc_probe; -- succeeds, and it should not
With That is the CI signature verbatim. With Control arm: leave the table attached and the same drop is correctly refused with So there are two separable product bugs, and both already have open PRs:
With (1) merged, the fuzzer sequence ends in a visible |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Good at least as an immediate measure.
fc7975b
|
The product fix is open: #120734 It goes through the load path rather than extending #110529, so it covers every engine at once: a table whose stored |
@alexey-milovidov we should fix the real root causes instead |
|
For the root causes: they are split across two open PRs, and I answered on #120734. The drop-side refusal is @ alexey-milovidov's #112805, which counts detached tables as dependents. #120734 is the load-side half: a server whose stored metadata names a collection that is already gone boots and stays introspectable, which also covers the cases where no |
Related: #113117
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Pin
ast_fuzzer_any_query = 0on the table DDL of six stateless tests that build a table from a SQL-created named collection, so the server-side AST fuzzer cannot leave metadata behind that names a collection the test then drops.Description
Under the Stress profile a table can survive its own
DROP TABLEwhile the test'sDROP NAMED COLLECTIONstill runs. The next server start then cannot load the leftover metadata, and withasync_load_databases = 0(a coin flip instress_runner.sh) that aborts the whole server, so CIDB records onlyCannot start clickhouse-server.Two injections combine.
ignore_drop_queries_probabilitymakesInterpreterDropQueryeither ignore aDROP TABLEor rewrite it toTRUNCATE; forS3(implementstruncate) andDistributed(takes the ignore branch) the client still gets rc 0 with the table present, so an exit-code-gated teardown proceeds.ast_fuzzer_any_querythen lets the fuzzer replay that DDL as aDETACH(metadata kept) or a__fuzz_Nclone inheriting the collection reference. The collection drop's guard usesisTableExist, false for a detached table, so the collection goes.Fix: pin
ast_fuzzer_any_query = 0on the invocations issuing table DDL for that table, restoring the setting's own default there only;SELECTandSHOW CREATEstay fuzzed. Merged precedent:03822_named_collection_drop_dependency_check.sh. Commit 2 (the twoRemotesiblings, 0 CIDB hits) is droppable whole to land only the proven ones.I do not pin
ignore_drop_queries_probability: #113117 removed those as useless, and with it forced to 1 and the pin in place every carrier fails loudly (NAMED_COLLECTION_IS_USED, orCode: 48) instead of stranding. Both directions: with a strand on disk the server exits 210 withCaught exception while loading metadata; with the pins, 24 armed runs of all six tests leave nothing behind and it boots clean. Removing the pin strands again.04512'sremote()arms need a shard on port 9000, so it is left to this PR's CI (its pristine version fails identically here).04626keeps a pre-existing ~20% stress-profile failure rate from the fuzzer mutating its data-producingINSERT(base 4/50), a different invariant, left unpinned so thes3()URI path stays covered.CIDB evidence and the three deliberately unpinned files
Signature:
test_name = 'Cannot start clickhouse-server'withNAMED_COLLECTION_DOESNT_EXISTin the context.30 days: 14 rows, 13 distinct PRs, 0 with
pull_request_number = 0, every one aStress test (*):04320_url_engine_dispatch_partition_and_format_named_collection.sh__fuzz_4clones04626_s3_base_setting_named_collection.sh04512_remote_missing_named_collection.sht_engine_sk/t_engine_tf04327_s3queue_server_credentials.sh__fuzz_4clone03822_named_collection_drop_dependency_check.sh__fuzz_1clone (already pinned)At 45 days it adds two rows with
pull_request_number = 0andhead_ref = 'master'(2026-08-07arm_msan, 2026-07-31arm_tsan), both stranding04320_..._n, so this is not PR-only.The carrier list is mechanical: a candidate creates and drops a collection SQL-side and persists an
engine definition naming it via
CREATE TABLE,CREATE OR REPLACE TABLEor a full-definitionATTACH TABLE(anASTCreateQuerywriting the same metadata, so grepping forCREATE TABLEalonemisses it). Ten candidates; three are left alone, re-checked with the injections armed:
04070_url_base_setting.sh,04546_postgresql_engine_settings.sql:URLandPostgreSQLoverrideneither
truncatenorstoresDataOnDisk, so the only reachable branch raisesCode: 48 Truncate is not supported by storage ..., aborting the statement stream before thecollection drop. The collection outlives the table, the safe direction.
04891_nats_credential_file_path_restriction.sql: its metadata-writing statement is a full-definitionATTACHwith an explicit UUID, so in anAtomicdatabase a clone either collides with the livetable's UUID or is rejected by
InterpreterCreateQuery.Workflow [PR]
Sync PR [sync-upstream/pr/118504]
Version info
26.9.1.1318(included in26.9and later)