Repository navigation
Conversation
`table_disk = true` means the disk's path holds this table's data rather than the database's. `QueryFuzzer::fuzzCreateQuery` mutates the column list and the key clauses and then renames the table to `<name>__fuzz_N`, but it left the storage `SETTINGS` untouched, so the clone mounted the parts of the table it was cloned from while declaring a schema and sorting key those parts do not satisfy. Only the engine-replacement branch cleared the settings, and it is not taken for a MergeTree clone. Measured on a local object-storage root: 29 of 37 clones the fuzzer created were reading the original table's parts. Reads of them failed with TYPE_MISMATCH, EXPECTED_END_OF_FILE on `primary.cidx`, and - when the surviving mutation was the `ORDER BY ... DESC` direction flip - a LOGICAL_ERROR from `PartsSplitter`, which is what aborted `Stress test (arm_release)` on master 27ee4ee. `deriveReverseOrder` returns `in_reverse_order = true` over an ascending index, `compareValues` inverts, every `RangeEnd` event sorts before its own `RangeStart`, and `splitPartsRangesImpl` throws on the resulting duplicate `PartRangeIndex`. The strip goes in `fuzzTableStorage`, the single helper both the outer storage clause and every view inner engine (`create.targets->getInnerEngines()`) pass through, and precedes the `!storage.engine` early return so a storage clause with no `ENGINE` is covered too. Both `changes` and `default_settings` are erased and an emptied node is pruned, mirroring `stripQuerySettings.cpp`: the owner formatter prints `SETTINGS` whenever the slot is non-null, so an empty node would serialize to a bare `SETTINGS` that fails to re-parse. `disk` itself is deliberately kept: without `table_disk` it only chooses where the clone stores its own data, so it cannot alias. The fuzzer still fuzzes queries against the original `table_disk` table and still wraps it through the engine-replacement branch. Co-Authored-By: Claude Opus 5 <[email protected]>
`position(query, 'table_disk')` counted any occurrence of the substring anywhere in a clone's text, which is not the contract the test asserts. The fuzzer's corpus is process-global (`getGlobalASTFuzzer` returns a function-local static) and `collectFuzzInfoRecurse` pools every identifier and literal it sees, so in a lane that arms `ast_fuzzer_runs` server-wide an unrelated identifier such as `test_table_disk_requires_disk` from `03355_mergetree_table_disk` can be substituted into a clone that carries no `table_disk` setting at all. The negative oracle would then count that clone and the test would fail even though the strip worked. Match the setting name as a whole word instead. The character classes are spelled out rather than using `\b` because inside a bash double-quoted string `\\b` collapses to `\b`, which the string-literal parser turns into a backspace byte, leaving a regex that matches nothing. This form has nothing for either layer to eat, and it matches both `SETTINGS table_disk = true` and the valueless `SETTINGS table_disk` shorthand that `ASTSetQuery::formatImpl` prints for a shorthand change. Both negative oracles also gain `query_kind = 'Create'`, so they cannot count a sibling oracle statement's own text by accident rather than by statement ordering, and a liveness control on the seed CREATE is added last: the seed genuinely carries the setting and is never rewritten in place, so it must match with and without the strip. A mangled pattern now fails loudly instead of passing vacuously. Co-Authored-By: Claude Opus 5 <[email protected]>
It said the mutated column list and sorting key are applied "below" this point. They are not: `fuzzColumnDeclarationList` and the `ORDER BY ... DESC` arm both run in the caller, `fuzzCreateQuery`. State the invariant without the location claim, in three lines instead of four. Co-Authored-By: Claude Opus 5 <[email protected]>
The oracles only checked that no clone carries `table_disk`. That is half of the contract: replacing the two selective erases in `fuzzTableStorage` with an unconditional `storage.reset(storage.settings)` satisfies every one of those lines while stripping `disk`, `index_granularity` and every other storage setting from every clone, so the fuzzer would stop exercising the storage clause at all and the test would not notice. Assert per carrier that `disk = disk(` still appears in at least one clone. `count() > 0` rather than a per-clone count, because the wrap arm that turns a clone into `Distributed`, `Buffer` or `Merge` rewrites its storage clause wholesale and legitimately drops the setting, so an equality would flake. The leading boundary class stops `table_disk = disk(` from satisfying the predicate, and the paren is written `[(]` so that neither bash nor the string-literal parser sees a backslash to consume. The file also drops its view and its two tables at the end, like the other tests on this plain_rewritable chassis. The clones go with the per-test database. Co-Authored-By: Claude Opus 5 <[email protected]>
The fuzzer's clone registry, original_table_name_to_fuzzed, is keyed by the bare
table name: getOriginalTableName just cuts at __fuzz_ (QueryFuzzer.cpp:1388).
It lives on a fuzzer that is a function-local static, created once per server
process and never recreated (executeQuery.cpp:3334), so an entry another test
left under the name "reader" is still there when this test runs. Seven other
stateless tests create a table called exactly that, and nothing on the server
side erases such an entry: getDropQueriesForFuzzedTables, the only code that
does, has no caller in executeQuery.cpp.
With the key already populated, iteration 1 can take the wrap arm at
QueryFuzzer.cpp:2234, which sets storage.settings = nullptr (:2297) and drops
the column list, so the clone carries no storage clause at all and
table_clones_keep_disk reads 0 while the fix is working. Only iteration 1 is
exposed: from iteration 2 the fuzzer has registered its own clone, and each
iteration fuzzes the previous one's output (base_ast = fuzzed_ast,
executeQuery.cpp:3663), so once the arm is taken every later clone inherits the
wrapper. Measured on a first clone: 5 of 250 executions wrapped with a populated
key, 0 of 249 with a per-database name.
${CLICKHOUSE_DATABASE} is unique per test execution, so a suffixed seed name is
one the fuzzer has never seen and the key is empty at iteration 1. The oracle
becomes deterministic rather than merely probable.
Only the two tables that are actually fuzzed are renamed. writer is created
through a client pinned to --ast_fuzzer_runs=0, so it never enters the registry
and needs no suffix.
Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 11 findings across my own cold passes
Also noticed, no change made: this test deliberately does not carry Also noticed, no change made: the oracles select a carrier's clones by substring over the whole Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20260910-065300 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20260910-061501 |
|
Workflow [PR], commit [866bbc5] AI ReviewSummaryThis PR strips Findings
Tests
Final VerdictStatus:
|
|
cc @qoega @PedroTadim, could you review this? The fuzzer renames a |
|
@groeneai are you sure this is the right fix? Maybe we should throw an error in an invalid setting combination |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 17 s compile time in total, 7 of them have a recent master baseline. |
|
It is the right fix for the producer, but you are right that it is not the whole story. I do not think the combination can be caught from the settings, though. The engine half is real without the fuzzer, and I think it matters more than the CI abort. Hand-written DDL: CREATE TABLE writer (key Int32, val UInt32) ENGINE = MergeTree ORDER BY key
SETTINGS table_disk = true, disk = disk(name = repro1_writer, type = object_storage,
object_storage_type = local, metadata_type = plain_rewritable, path = 'disks/repro1_engine/');
SYSTEM STOP MERGES writer; -- then 4 inserts of 50 rows, so 4 parts, all written ascending
CREATE TABLE reader (key Int32, val UInt32) ENGINE = MergeTree ORDER BY key DESC
SETTINGS table_disk = true, disk = disk(read_only = true, name = repro1_reader,
type = object_storage, object_storage_type = local, metadata_type = plain_rewritable,
path = 'disks/repro1_engine/');
SELECT count(), sum(key) FROM reader SETTINGS
merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability = 1,
max_threads = 8, use_query_condition_cache = 0;That aborted the server on the first attempt at The abort is the lucky case, which is what stopped me treating this as a CI-only problem: the Where such a throw can live: not in I have that repro, so I can send the load-time check as a separate PR if you want it. For this PR: keep the strip, or close it in favour of the engine-side check? I lean to keeping it, since a clone that mounts another table's data root yields no useful fuzz signal either way (on a pristine build the same clone also produced |
|
One correction to what I just wrote, since it is the part that decides the shape of an engine-side fix: the load-time check cannot be derived from the parts. I planned exactly that (verify each part's primary index is non-decreasing under the declared key) and then measured it dead: with For pricing the decision, this is the same fixture at default settings (4 ascending parts, keys 0..199; control is the same reader declaring
The full scan is the only one of those that never calls So three mechanisms survive, and each asks for a call I do not think I should make alone on a shipped on-disk contract:
I lean to (2) if that compatibility break is acceptable, otherwise (1) with a sorting-key-only descriptor that refuses on mismatch and trusts descriptor-less roots. I am happy to implement whichever you or the owner of the feature prefer. One input for the decision: merging this PR removes the only automated detector CI currently has for the state. |
…sets no-darwin)
CI finish ledger - ad24984Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
No other check failed on this head: 151 SUCCESS, 20 SKIPPED, 0 queued or running at the time of measurement. Session id: cron:our-pr-ci-monitor:20260910-130137 |
| /// sorting key its caller applies. Without the setting the clone stores its own data. | ||
| if (storage.settings) | ||
| { | ||
| std::erase_if(storage.settings->changes, [](const SettingChange & change) { return change.name == "table_disk"; }); |
There was a problem hiding this comment.
This narrows the fuzzer surface, but it also removes the only automated detector for a still-supported table_disk failure mode. The docs treat table_disk = true as the supported one-writer/many-readers shared-storage setup, and the current engine still accepts a readonly reader over the same root with incompatible metadata: MergeTreeData::loadDataPart skips part-consistency checks on readonly disks (loadColumnsChecksumsIndexes(..., !part_disk_ptr->isReadOnly())), so a reader declaring a different ORDER BY can still return wrong results or hit LOGICAL_ERROR, as in the repro already captured in this PR discussion. After this line lands, CI goes green because the fuzzer no longer emits that state, not because the feature is guarded. I think this needs either the engine-side validation/regression in the same change, or at least a linked follow-up issue plus another test that keeps the user-visible table_disk path covered.
|
🕵️ On the engine bug this leaves open — I'd argue for validating against the parts rather than against a descriptor or a sibling table. The three symptoms you measured ( Why I'd prefer it to the alternatives that have come up: A sibling-table check needs the sibling to exist. Parts outlive tables — create A ascending, drop it, create B descending, and B mounts incompatible parts with nothing to compare against. Same for Forbidding two tables per root would refuse configurations that work today. The setting's own docs list A persisted structure descriptor is sound in principle but cannot reach the cases that matter. The part check needs no new file, no new setting, no migration policy, and works on read-only roots, on roots written by any version, and on the Separately and worth landing first either way: And since there's no issue for the engine bug yet, it would be worth filing one with the deterministic two-table repro from your description, so it doesn't live only in a merged CI-fix PR. @groeneai can then go with option 3 in a new PR? |
|
Yes, sending option 3 as a new PR. Scope I plan, so you can veto early:
Agreed on landing that first, and closing #119159 does not delay CI. Measured over 30 days, this state reaches CI by two independent routes: the AST fuzzer (13 rows, last 2026-09-08) and, as of today, the stress lanes (3 rows: On validating against the parts: it is the strongest available check, and it does catch a multi-granule part written with the opposite direction. It does not close all three, and here are the two misses I measured (outcomes only, detail in the 09:37 comment above):
So it converts some silent wrong answers into a legible error without making the root safe. Happy to send it as its own PR if you want it as a best-effort check; your call. On the issue: agreed, and with option 3 the wrong-answer half stays by design, so the issue is the only public record of it. I will file it with the deterministic two-table repro and the default-settings numbers ( |
|
Option 3 is up as #119295. One deviation from the scope I posted above, so it is not a surprise in review: instead of converting The reason is measured. The Both alternatives are still yours to take: the literal |
… key A part's marks are physically ordered by the sorting key the part was written with. `table_disk` mounts whatever parts are already under the disk root, and nothing records that key, so a table can declare the opposite direction over parts written ascending - two tables over one root is a documented shape. `splitPartsRangesImpl` then sorts each range's RangeStart/RangeEnd events by the primary index value at the range's begin and end mark, compared in the declared order. With the opposite direction every RangeEnd sorts before its own RangeStart, so parts_ranges[0] is a RangeEnd, the pre-seed inserts that range's PartRangeIndex, and the matching RangeStart fails to emplace: LOGICAL_ERROR at :547, or the chassert at :530 one line earlier in builds with assertions. When the violating range is not the global minimum nothing fires at all and the part_index_start_to_range lookups read a default-constructed MarkRange. Check each range against the declared order where the loop already has both values, and report the invalid input instead. The check is placed before the sort rather than at :547 because the chassert fires first in every debug and sanitizer build, which is where most of the CI occurrences are; converting the throw alone would leave those aborting. With the precondition established, :530, :547 and :618 become internal assertions unreachable from a user configuration and stay as they are. `splitIntersectingPartsRangesIntoLayers` is deliberately not guarded: it derives its borders from interior mark values, which an endpoint check does not constrain, and it cannot abort, so its failure mode is wrong results. Requested by PedroTadim in ClickHouse#119159. Co-Authored-By: Claude Opus 5 <[email protected]>
Related: #116473
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Stress test (arm_release)aborted on master27ee4ee716b4withLogical error: 'PartsSplitter expected unique range'(CI report); no issue exists, so that run is the provenance.The producer is the query fuzzer.
table_disk = truepoints the disk at the table's own data, not the database's.fuzzCreateQuerymutates the column list and key clauses and renames the table to<name>__fuzz_Nbut left the storageSETTINGSuntouched, so the clone read the cloned-from table's parts under a schema they do not satisfy: 29 of 37 clones did. Those reads failed withTYPE_MISMATCH,EXPECTED_END_OF_FILE, and the error above when the surviving mutation was theORDER BY ... DESCflip:in_reverse_orderover an ascending index sorts everyRangeEndbefore its ownRangeStart, sosplitPartsRangesImplsees a duplicatePartRangeIndex.I drop
table_diskinfuzzTableStorage, the one helper both the outer storage clause and every view inner engine (create.targets->getInnerEngines()) pass through, before its!storage.engineearly return.diskis kept: withouttable_diskit only chooses where the clone stores its own data, so it cannot alias. The originaltable_disktable is still fuzzed; only the mutation of foreign parts is removed.05166_ast_fuzzer_table_disk_cloneasserts that no clone of either carrier keepstable_diskand thatdiskitself survives, with a per-carrier positive control that the fuzzer did rewrite the CREATE. Removing the twoerase_iflines reddens both carriers; clearing the wholeSETTINGSnode instead reddens the retention lines. 100/100 runs pass.Merged #116473 closed the
ALTER ... MODIFY ORDER BYroute to the same state. The engine assertion is unchanged and stays reachable without the fuzzer: twotable_disktables over one object-storage root declaring opposite key directions reach it deterministically. Repairing that means refusing such a table; not folded in here. I also noticed a clone keeps the original's explicitUUID, observed only as a rejectedTABLE_ALREADY_EXISTS.Workflow [PR]
Sync PR [sync-upstream/pr/119159]