Repository navigation
Conversation
Pin enable_join_runtime_filters=1 to avoid wrong-results bug when the query condition cache returns stale data after INSERT with runtime filters disabled and query_plan_join_shard_by_pk_ranges enabled. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Pre-PR Validation Gate (Session 04605368)a) Deterministic repro? b) Root cause explained? c) Fix matches root cause? d) Test intent preserved? e) Both directions demonstrated?
|
|
cc @vdimir — could you review this? It pins enable_join_runtime_filters=1 in a flaky test to work around a wrong-results bug where the query condition cache serves stale data after INSERT when runtime filters are disabled, causing JOIN with sparse columns to return 0 rows instead of the expected result. |
|
Workflow [PR], commit [76966d3] AI ReviewSummaryThis PR stabilizes ClickHouse Rules
Final Verdict
|
|
This doesn't look good.
@groeneai there is a bug somewhere in the query condition cache or inside the optimization. You must investigate this. |
|
Closing this band-aid fix in favor of a proper C++ fix that addresses the root cause. The new PR will disable the query condition cache's reader-level behavior (ceilRowsToCompleteGranules) when the join-by-shards optimization is active, rather than pinning enable_join_runtime_filters=1 in the test. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
What this PR does
Pins
enable_join_runtime_filters = 1in the flaky test02845_join_on_cond_sparseto work around a wrong-results bug in the query condition cache.Root cause
When three randomized settings align —
enable_join_runtime_filters = 0,use_query_condition_cache = 1, andquery_plan_join_shard_by_pk_ranges = 1— the second SELECT in the test returns 0 rows instead of the expected 1 row.Causal chain: With
enable_join_runtime_filters = 0, the left-side ON conditiont1.attr != 0is not pushed down as a runtime filter but applied as a post-join additional filter. Whenuse_query_condition_cache = 1andquery_plan_join_shard_by_pk_ranges = 1are also active, the query condition cache incorrectly serves stale results from the first SELECT (which evaluatedt1.attr != 0on the original single-row part containing onlyattr=0) for the second SELECT (which should see the newly insertedattr=1row in a new part). The cache fails to account for the new part added by the intervening INSERT.Evidence
SET enable_join_runtime_filters=0forced, full randomizationSET use_query_condition_cache=1SET query_plan_join_shard_by_pk_ranges=1+ MergeTree randomizationSET enable_join_runtime_filters=1), full randomizationCIDB failure data (7 days)
9 failures across 5 unrelated PRs and master —
enable_join_runtime_filters=Falsepresent in 100% of failures. Cross-analysis of 32+ local failures confirmeduse_query_condition_cache=1(100%, p < 10⁻¹⁰) andquery_plan_join_shard_by_pk_ranges=True(100%, p < 10⁻¹⁵) as co-triggers.Why this fix is correct
enable_join_runtime_filters=1preserves the test's ability to catch sparse column join bugs🤖 Generated with Claude Code