Repository navigation
Conversation
Pre-PR validation gate (per
|
|
cc @rschu1ze @nikitamikhaylov @alexey-milovidov — could you review this? It implements the directive in #104203 to refuse |
|
Workflow [PR], commit [3d2531b] Summary: ❌
AI ReviewSummaryThis PR adds a write-side gate for PR Metadata
Missing Context / Blind Spots
Final VerdictStatus: ✅ Approve |
…QCC in fuzzer profile Follow-up to commit 0eb3d0e9 (QCC writability gate). The CI on PR ClickHouse#104225 surfaced that the previous tier-based criterion was much too coarse: it refused writes for ANY non-default `Beta` or `Experimental` setting, which silently broke ~6 sibling QCC tests across ~16 build/sequential variants: - `04208_query_condition_cache_writable_104203` (this PR's regression test) - `03229_query_condition_cache_profile_events` - `03229_query_condition_cache_drop_cache` - `03229_query_condition_cache_system_table` - `03460_query_condition_cache_with_projections` - `03783_autopr_dataflow_cache_reuse_qcc` `--diagnose-random-settings` minimised every parallel-randomization failure to a single culprit: `--session_timezone <something>`. `session_timezone` is `Beta`-tier and CI flips it on most runs, so the gate refused QCC writes wholesale and the tests, which expect the cache to be populated, observed an empty cache. The non-randomized failure of `03783` had the same root cause: it explicitly enables `automatic_parallel_replicas_*` (Experimental tier) which is also routinely used by ordinary queries. Replace the tier-based criterion with strict NAME-pattern matching, exactly as the directive on issue ClickHouse#104203 spelled out ("any 'relaxed' / 'allow_suspicious' / 'experimental' flags"): * `allow_suspicious_*` — explicit opt-in to suspicious type / index combinations; * any name containing `relaxed` — type-coercion or other validity relaxations; * `allow_experimental_*` ONLY when the setting is currently in the `EXPERIMENTAL` tier. This preserves writes for promoted-but-renamed settings such as `allow_experimental_analyzer` (now `Production`) while still catching genuinely experimental ones like `allow_experimental_funnel_functions`. This is what the AST fuzzer was actually flipping that produced the bug in the first place. Beta-tier settings (`session_timezone`, `parallel_replicas_*`, `enable_join_runtime_filters`, `low_priority_query_wait_time_ms`, ...) are routine and must not block writes. Also disable the QueryConditionCache for the AST fuzzer query profile (`ci/jobs/scripts/fuzzer/query-fuzzer-tweaks-users.xml`) — the second part of the directive. The fuzzer tweaks-users profile sets dozens of `allow_experimental_*` and `allow_suspicious_*` flags as defaults, exactly the conditions that produce incoherent QCC verdicts. Disabling QCC here removes the actual cause; the gate above is defense-in-depth against future fuzzer variants. Regression test `04208`: pin `add_minmax_index_for_numeric_columns=0` (otherwise the auto MinMax index can prune marks before the QCC sees the predicate) and the two prewhere settings, mirroring the setup the existing QCC tests already use. This makes the test deterministic regardless of CI randomization. Update the header comment to reflect the new criterion. Verified locally: - 100 / 100 stress runs (5 QCC tests x 20 iterations, randomization on) pass - Manual scenario sweep: `allow_suspicious_*`, `allow_experimental_*` (EXPERIMENTAL) still correctly refuse writes; `session_timezone`, `automatic_parallel_replicas_*`, `allow_experimental_analyzer` (Production) correctly allow writes; setting an experimental flag back to its default value correctly allows writes - Read-after-write: cache entries written by a normal-context query remain readable from a non-writable context CI report: ClickHouse#104225
|
Pushed What brokeAfter commit
What changed1. Gate is now strictly name-pattern based ( Refuses writes only when a non-default setting matches one of:
This is exactly what the directive on #104203 specified and what the AST fuzzer was actually flipping. 2. QCC disabled for the AST fuzzer profile (
3. Regression test Pin Verification
|
…tal_* settings Two gaps in the previous gate were caught in review on PR ClickHouse#104225: 1. Beta-tier `allow_experimental_*` settings (e.g. `allow_experimental_database_iceberg`, `allow_experimental_correlated_subqueries`, `allow_experimental_database_unity_catalog`, `allow_experimental_database_glue_catalog`, `allow_experimental_delta_kernel_rs`) bypassed the previous tier check that only matched `Experimental`. They have non-production semantics and remain candidates for cache poisoning. Block them by changing the tier check from `tier == EXPERIMENTAL` to `tier != PRODUCTION` (Obsolete is filtered earlier). 2. Some `allow_experimental_*` names are aliases pointing at a canonical setting that does not start with `allow_experimental_`, so the canonical-only check let them slip through. Examples: `allow_experimental_lightweight_update` -> `enable_lightweight_update` (Beta), and `allow_experimental_insert_into_iceberg` -> `allow_insert_into_iceberg` (Beta). For each changed canonical, also check its aliases against the same gate; aliases inherit the canonical's tier. `allow_experimental_analyzer` remains in `Production` tier and continues to permit QCC writes - it kept the legacy `allow_experimental_` name for backward compatibility but is fully stable. Verified locally: * baseline (no changed settings): writes * `allow_experimental_database_iceberg = 1` (Beta canonical): blocked * `allow_experimental_lightweight_update = 0` (Beta alias): blocked * `allow_experimental_insert_into_iceberg = 1` (Beta alias): blocked * `allow_experimental_funnel_functions = 1` (Experimental): blocked (existing) * `allow_suspicious_low_cardinality_types = 1`: blocked (existing) * `session_timezone`, `enable_join_runtime_filters`, `max_threads`: still write * `allow_experimental_analyzer = 0` (Production): not blocked by this gate (the empty cache is independent — old analyzer doesn't reach the QCC write path) Regression test updated with two new cases covering the Beta canonical and Beta alias scenarios; the existing scenarios remain green.
|
Thanks for the catch! Pushed 1. Beta-tier 2. Aliases are now also checked. Some Verified locally on debug build:
Regression test |
The header comment for isQueryConditionCacheWritable described the gate as blocking allow_experimental_* only in the EXPERIMENTAL tier, but the implementation in Settings.cpp now also blocks the Beta tier (and aliases). Update the comment to match. See ClickHouse#104225 (comment).
…terInfo Bot review on PR ClickHouse#104225 surfaced that the `isQueryConditionCacheWritable` predicate added in commits 0eb3d0e9 / 1860c81 / bfa2364 was wired into the three `MergeTree` write paths but missed a fourth, very recently added one: the object-storage QCC write in `StorageObjectStorageSource::generate` (introduced by PR ClickHouse#102115 -- "Query condition cache for iceberg tables", merged 2026-05-07). That site populates the cache from `Iceberg`/`S3`/`Azure` queries when the format reader produces matched-bucket information, keyed by `FormatFilterInfo::condition_hash` -- which until now was created based only on `use_query_condition_cache`, with no writability check. So a query against an object-storage table running with `allow_suspicious_low_cardinality_types = 1` or any non-`Production` `allow_experimental_*` setting could still poison the cache for a subsequent default-settings query, leaving issue ClickHouse#104203 only partially closed for the engine as a whole. Mirror the existing `MergeTreeReaderSettings::query_condition_cache_writable` flag on `FormatFilterInfo`. Set it from the same predicate (`Settings::isQueryConditionCacheWritable`) at the same site where `condition_hash` is computed. Gate the `query_condition_cache->write` call in `StorageObjectStorageSource::generate` on the new flag. Reads through `condition_hash` stay open -- the lookup-side path remains valid because entries written from "writable" contexts are correct, and the same context that wrote nothing can still benefit from cache hits produced by ordinary queries. Coverage: extended `tests/integration/test_storage_iceberg_with_spark/test_query_condition_cache.py` with `test_query_condition_cache_not_writable_with_relaxed_settings`, parametrized across (`s3`, `azure`, `local`) and three triggering settings (`allow_suspicious_low_cardinality_types`, `allow_experimental_funnel_functions` [`Experimental` tier], `allow_experimental_database_iceberg` [`Beta` tier]). The test asserts that `system.query_condition_cache` stays empty after a filtered query in any of those contexts. Stateless test `04208_query_condition_cache_writable_104203` continues to exercise the `MergeTree` write paths and is unaffected.
|
Good catch — gated in Fix: mirror Files:
Coverage: extended Local verification: |
Status update — ready for human reviewAll bot feedback has been addressed across 5 commits (last commit CI status on commit
|
| Job | Conclusion |
|---|---|
| Style check | ✅ SUCCESS |
| Code Review | ✅ SUCCESS |
| CI Tests | ✅ SUCCESS |
| Bugfix validation (functional tests) | ✅ SUCCESS |
| Bugfix validation (integration tests) | ✅ SUCCESS |
| Build (arm_tidy) | ✅ SUCCESS |
| Fast test | ❌ FAILURE — chronic flake 02932_refreshable_materialized_views_2 |
| Everything else | DROPPED (blocked on Fast test) |
About the chronic flake
02932_refreshable_materialized_views_2 has hit 10 unrelated PRs in the last 30 days (last hit 2026-05-08 11:58 UTC, just 1.5 hours ago) and is unrelated to this PR — it's a known chronic flake in the refreshable materialized view logic, not caused by anything here. CIDB confirms it has never failed in any test_query_condition_cache* run.
Could a maintainer please re-run the Fast test job? With that re-run, the dependent builds + downstream jobs will execute and the PR can move toward merge.
About the bugfix validation result
The Bugfix validation jobs report Failures: 6/15 in the info field, but both jobs are conclusion OK. The breakdown:
| Test | Count | Result on master HEAD | Interpretation |
|---|---|---|---|
test_query_condition_cache_not_writable_with_relaxed_settings[*] |
9 | ❌ FAIL | ✓ Expected — this is the regression test for #104203, correctly proves the bug exists on master |
test_query_condition_cache[*] |
3 | ✅ PASS | Sanity-only test, doesn't exercise the bug |
test_query_condition_cache_nondeterministic_functions[*] |
3 | ✅ PASS | Sanity-only test for unrelated path |
The Failures: 6/15 field is the count of new tests that DIDN'T fail on master HEAD (i.e., happy-path / sanity tests that don't exercise the bug). The 9 actual regression tests correctly fail on master HEAD, demonstrating the bug exists, and pass on PR HEAD with the fix — which is precisely what bugfix validation is checking for. Job conclusion OK is the correct verdict.
cc @rschu1ze @nikitamikhaylov @alexey-milovidov — would appreciate a final review whenever you have a moment.
|
Dear @scanhex12, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
44486b8 to
3d2531b
Compare
|
Rebased onto current master ( The conflict was at the three shared QCC write sites, where master had added new guards since this branch was opened:
Resolution composes both sides: each write site now AND-s master's new guard with this PR's Local verification on a debug build at this commit:
|
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 64/64 (100.00%) | Lost baseline coverage: none · Uncovered code |
|
CI finished on rebased HEAD
No PR-caused failures. Moving to review. Session id: cron:our-pr-ci-monitor:20260611-160000 |
…xed settings The QueryConditionCache is keyed by the filter expression's action-graph hash, which captures predicate structure but not evaluation profile. A query running under settings that change PREWHERE/WHERE data-skipping outcomes (allow_suspicious_*, relaxed, non-Production allow_experimental_*) could write a "no marks match" verdict that a later ordinary query reads back, returning silently wrong rows (issue ClickHouse#104203, found via the AST fuzzer's server-side oracle). Add Settings::isQueryConditionCacheWritable() and gate all four QCC write sites (MergeTree PREWHERE, ReadFromMergeTree post-PK/skip-index, updateQueryConditionCache optimizer, object-storage source). Reads stay open. Also disable the cache in the fuzzer oracle profile. Closes: ClickHouse#104203 Co-Authored-By: Claude Opus 4.8 <[email protected]>
3d2531b to
f9a065f
Compare
|
Rebased onto current master ( The only conflict was at the PREWHERE write site in Local debug build clean; Session: cron:clickhouse-worker-slot-1:20260620-071600 |
# Conflicts: # src/Core/Settings.cpp
|
Merged current Local debug build clean; Session: cron:clickhouse-worker-slot-1:20260620-224600 |
|
The fix looks overblown and it is not even clear if there is a problem in normal builds at all (the PR addresses a hypothetical issue in the query fuzzer). I'll comment in #104203 how to go forward. |
Closes #104203.
The
QueryConditionCacheis keyed by the action-graph hash of the predicate, which captures the predicate's structure but not the evaluation profile. Settings that changePREWHERE/WHEREevaluation outcomes (type coercion, constant folding, data-skipping decisions) — for exampleallow_suspicious_low_cardinality_types,allow_experimental_correlated_subqueries, or any non-Production-tier setting — can produce a "no marks match" verdict for a given action hash that is invalid under the default settings. A subsequent benign query whose filter hashes to the same key then reads back that verdict and silently returns the wrong rows. The bug surfaces in CI when the AST fuzzer's server-side oracle (#99980) runs queries against a smallMergeTreetable for ~1 hour: roughly 8% of QCC entries become all-zero "no marks match" verdicts that poison subsequent queries.This PR implements the directive in #104203:
Settings::isQueryConditionCacheWritable()returnsfalseif any non-default setting is either:Beta,Experimental) — by definition under development and prone to semantic shifts; orallow_suspicious_*or containsrelaxed— explicit opt-ins that bypass safety checks.We deliberately do NOT match
allow_experimental_*by name: settings such asallow_experimental_analyzerhave been promoted to default but kept their name for backwards compatibility, and matching the prefix would block writes from ordinary queries that just enable the analyzer. Real experimental settings are caught by the tier check above.Comparing the current value to the default (rather than relying on the
is_changedflag) is necessary because tests and applications routinely callSET name = default_value, which sets the internalis_changedflag without actually changing behaviour.Reads from the cache remain unaffected. An entry written by a normal-context query is still readable by any query, because the verdict itself is valid for the data and predicate that produced it. Only the writes that could poison the cache are suppressed.
The check is applied at all three QCC write sites:
MergeTreeSelectProcessor::read— PREWHERE write for unmatched marksReadFromMergeTree::selectRangesToRead— write after primary key / skip-index pruningupdateQueryConditionCacheplan optimizer — gatesFilterTransformwrites viaFilterStep::conditionThe propagation goes through
MergeTreeReaderSettings::query_condition_cache_writable(for the two MergeTree-side writes) andQueryPlanOptimizationSettings::query_condition_cache_writable(for the optimizer-side write).Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Refuse to write to the
QueryConditionCachefrom contexts that have changed an experimental, beta, suspicious, or relaxed setting. Such settings can changePREWHERE/WHEREevaluation outcomes (type coercion, constant folding, data-skipping decisions) without changing the action-graph hash that keys the cache, which previously caused the cache to be poisoned with bogus "no marks match" verdicts that were served back to subsequent benign queries (returning silently wrong rows). Reads from the cache are still permitted from any context. #104203.Documentation entry for user-facing changes