Skip to content

Fix flaky 04490_join_runtime_filters_index_analysis - #112467

Merged
vdimir merged 1 commit into
masterfrom
vdimir/fix_04490_join_runtime_filters_index_analysis
Jul 30, 2026
Merged

vdimir merged 1 commit into
masterfrom
vdimir/fix_04490_join_runtime_filters_index_analysis

Conversation

@vdimir

@vdimir vdimir commented Jul 29, 2026 •

Copy link
Copy Markdown
Member

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107666&sha=df23e1d1e81fab78c6c717fdf63b6928f95461a5&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29

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

...

Version info

  • Merged into: 26.8.1.415 (included in 26.8 and later)

@clickhouse-gh

clickhouse-gh Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a7b4e3e]

Summary: ✅


AI Review

Summary

This PR stabilizes 04490_join_runtime_filters_index_analysis by pinning join_runtime_filter_min_probe_rows = 0, which matches the CI diagnosis for the reported failure. The fix is directionally correct, but I do not think it is complete: sibling runtime-filter index-analysis tests still assert pruning ProfileEvents without overriding the same randomized setting, so the same flake class remains in the suite.

Findings

⚠️ Majors

  • [tests/queries/0_stateless/04490_join_runtime_filters_index_analysis.sql:38] The stateless runner injects randomized settings before the test file, and only an explicit SET/SETTINGS or a no-random-settings tag overrides them. That is why the reported failure reproduced with --join_runtime_filter_min_probe_rows 6894: joinRuntimeFilter.cpp skips building the runtime filter whenever the probe-side estimate is at most that threshold, which flips the expected RuntimeFilterGranules* checks from 1/1 to 0/0. This new SET fixes 04490, but the same unpinned gate is still present in tests/queries/0_stateless/04611_join_runtime_filters_index_analysis_skip_index.sql, tests/queries/0_stateless/04612_join_runtime_filters_index_analysis_multi_key_anti.sql, and tests/queries/0_stateless/04498_join_runtime_filters_multihop.sql, all of which use 2000-row probe sides and assert pruning ProfileEvents as well.
    Suggested fix: pin join_runtime_filter_min_probe_rows = 0 in those files too (or tag them no-random-settings if you want to opt out more broadly).
Final Verdict

Changes requested: extend the same pin to the sibling runtime-filter tests that still rely on randomized join_runtime_filter_min_probe_rows, otherwise the CI flake remains in the suite.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 29, 2026
-- Left-side join pruning is intentionally disabled under parallel replicas, so pin PR off to
-- exercise the feature (the ParallelReplicas CI job otherwise forces it on).
SET enable_parallel_replicas = 0;
SET join_runtime_filter_min_probe_rows = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pin is correct for 04490, but it leaves the same random-settings failure mode in the sibling pruning tests. The stateless runner injects --join_runtime_filter_min_probe_rows before the file, and only an explicit SET/SETTINGS or a no-random-settings tag overrides it; that is why the failing seed here (6894) suppressed BuildRuntimeFilter and turned the expected RuntimeFilterGranules* rows from 1/1 into 0/0.

04611_join_runtime_filters_index_analysis_skip_index.sql, 04612_join_runtime_filters_index_analysis_multi_key_anti.sql, and 04498_join_runtime_filters_multihop.sql still assert RuntimeFilterGranules* > 0 on 2000-row probe sides without pinning this setting, so the same probe_size <= join_runtime_filter_min_probe_rows branch can still disable the filter there. Please apply the same SET join_runtime_filter_min_probe_rows = 0 (or opt those files out of random settings) as part of the fix.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai make correspoding changes in this PR

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Measured all four files on a master debug build (26.8.1.1, 74a068f2), running each unmodified against its .reference with --join_runtime_filter_min_probe_rows injected as a client option, then again with the pin added. Two things came out different from the bot comment.

04611 and 04612 reproduce; 04498 does not.

test default injected 10000 injected 10000 + pin
04490 pass fail (6 rows 1 1 -> 0 0) pass
04611 pass fail (1 1 -> 0 0) pass
04612 pass fail (1 1 -> 0 0) pass
04498 pass pass pass

04498 passes across the whole randomizer range (randint(1, 10000): tested 1, 2, 10, 100, 500, 999, 1000, 1001, 2000, 3000, 5000, 8000, 9999, 10000). The reason is in the guard's input rather than in the guard: join_runtime_filter_min_probe_rows is only consulted through join_step->getInputRowsEstimation(JoinTableSide::Left) (joinRuntimeFilter.cpp:253), and left_rows_estimation is populated at exactly one place, join_step->setOptimized(entry->estimated_rows, lhs_estimation, rhs_estimation, ...) inside the join reordering loop (optimizeJoin.cpp:1375). 04498 pins SET query_plan_optimize_join_order_limit = 0, so optimizeJoin takes the early return at optimizeJoin.cpp:1521-1530 and calls setOptimized() with no arguments, leaving left_rows_estimation as nullopt. The probe_size && *probe_size <= ... test at :254 then cannot fire at any threshold value.

Both directions check out: removing only that SET from 04498 makes it fail under injection 10000 while still passing at the default, and adding SET query_plan_optimize_join_order_limit = 0 to 04612 makes 04612 pass under injection 10000.

04498 is still worth pinning, for a different reason. query_plan_optimize_join_order_limit is itself randomized (clickhouse-test:1649, 0 with probability 0.05 else one of 1/5/10/20/64), so 04498's immunity rests on its own file-level SET winning over the injected value. That holds today, but it makes the immunity incidental rather than structural, so the pin is cheap insurance rather than a no-op guard against a reproducing failure.

#111691 already does all of this. @ alexey-milovidov's open PR adds SET join_runtime_filter_min_probe_rows = 0 to 04490, 04498, 04611, 04612 and 04493, one line each, immediately after SET enable_join_runtime_filters = 1. So the sibling coverage the bot asked for already exists there and is not missing from the tree, only unmerged.

That leaves a merge-order detail rather than a missing fix: git merge-tree of the two heads resolves cleanly (both insertions are at different offsets), but the merged 04490 then carries the pin twice, at lines 32 and 39. Harmless, just redundant.

Given that, my suggestion is to leave this PR as the single-line 04490 fix and let #111691 carry the three siblings, since it already has them and also covers 04493 which is outside this PR's scope. If you would rather have the siblings here so 04490 does not wait on #111691, the diff is one line per file, inserted right after each file's existing SET enable_parallel_replicas = 0;:

--- a/tests/queries/0_stateless/04611_join_runtime_filters_index_analysis_skip_index.sql
+++ b/tests/queries/0_stateless/04611_join_runtime_filters_index_analysis_skip_index.sql
@@ -11,6 +11,7 @@
 -- Left-side join pruning is intentionally disabled under parallel replicas, so pin PR off to
 -- exercise the feature (the ParallelReplicas CI job otherwise forces it on).
 SET enable_parallel_replicas = 0;
+SET join_runtime_filter_min_probe_rows = 0;
 
 -- Bloom filter in skip index
 DROP TABLE IF EXISTS bf_fact;
--- a/tests/queries/0_stateless/04612_join_runtime_filters_index_analysis_multi_key_anti.sql
+++ b/tests/queries/0_stateless/04612_join_runtime_filters_index_analysis_multi_key_anti.sql
@@ -22,6 +22,7 @@
 -- Left-side join pruning is intentionally disabled under parallel replicas, so pin PR off to
 -- exercise the feature (the ParallelReplicas CI job otherwise forces it on).
 SET enable_parallel_replicas = 0;
+SET join_runtime_filter_min_probe_rows = 0;
 
 CREATE TABLE mk_fact (a UInt64, b UInt64, v UInt64)

I verified both of those exact insertions pass at the default and under injection 10000, and that they do not change any other assertion in either file. I have no push access to this branch, so this is a paste rather than a commit. I went with the targeted SET over no-random-settings since only this one setting is at fault and the tag would drop the rest of the coverage.

@vdimir
vdimir added this pull request to the merge queue Jul 30, 2026
Merged via the queue into master with commit b2109d2 Jul 30, 2026
180 checks passed
@vdimir
vdimir deleted the vdimir/fix_04490_join_runtime_filters_index_analysis branch July 30, 2026 10:44
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 30, 2026
pull Bot pushed a commit to sowelswl/ClickHouse that referenced this pull request Sep 22, 2026
…erministic_condition

The test asserts that a JOIN runtime filter is still moved into PREWHERE under
FINAL. It pinned enable_join_runtime_filters but not the threshold the optimizer
compares the probe-side ROW ESTIMATE against, and that estimate is not the real
row count: query_plan_optimize_join_order_randomize, randomized by the test runner,
replaces it with a uniform draw in [1, 10000000]. With the drawn pair (688112, 5964)
the estimate becomes 5135, the filter is declined for a seemingly small probe side,
and the assertion reads 0 instead of 1.

Pin the threshold to 0, which is documented to always build the filter, so the
assertion no longer depends on an estimate. Same shape as ClickHouse#111691 and ClickHouse#112467.

The join order randomizer stays unpinned on purpose, so this test keeps exercising
randomized join statistics. At a zero threshold the runtime-filter pass reads no row
estimate, and it runs before the physical join is chosen, so a randomized estimate
can no longer suppress the filter. It still varies the hash join implementation
chosen afterwards; the assertion holds at both implementations observed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants