Skip to content

Pin join_runtime_filter_min_probe_rows in tests that assert runtime filter effects - #111691

Merged
rienath merged 9 commits into
masterfrom
fix-join-runtime-filter-min-probe-rows-flaky-tests
Jul 31, 2026
Merged

rienath merged 9 commits into
masterfrom
fix-join-runtime-filter-min-probe-rows-flaky-tests

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • CI Fix or improvement (changelog entry is not required)

#104860 added the setting join_runtime_filter_min_probe_rows (default 1000) and randomizes it in clickhouse-test between 0 and 10000. Tests that assert side effects of the runtime filter actually being built — BuildRuntimeFilter steps in EXPLAIN output, or RuntimeFilterGranulesConsidered/RuntimeFilterGranulesDropped/index-analysis counters — over probe sides of only tens to a few thousand rows now fail whenever the randomized threshold exceeds the estimated probe size, because the runtime filter is skipped.

Pin join_runtime_filter_min_probe_rows = 0 in those tests, restoring the behavior they were written against (the dedicated test 04201_join_runtime_filter_min_probe_rows keeps covering the skip itself). Observed failing since the merge of #104860, e.g. 03394_distributed_shuffle_join_with_filter / _with_in / _with_aggregation (missing BuildRuntimeFilter in the EXPLAIN reference) and 04612_join_runtime_filters_index_analysis_multi_key_anti (index-analysis counters flip to 0): https://d1k2gkhrlfqv31.cloudfront.net/clickhouse-test-reports-private/json.html?PR=65003&sha=a867fe9e119f88fd563055ae403e90120a26e374&name_0=PR — the remaining tests in the diff assert the same effects with sub-threshold probe sizes and fail the same way under randomization.

Caused by: #104860
Related: #110968
Closes: #112574

Version info

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

…ilter effects

#104860 added the setting `join_runtime_filter_min_probe_rows` (default 1000) and
randomizes it in `clickhouse-test` between 0 and 10000. Tests that assert side
effects of the runtime filter being built — `BuildRuntimeFilter` in `EXPLAIN`
output or `RuntimeFilterGranules*`/index-analysis counters — over probe sides
of only tens to a few thousand rows now fail whenever the randomized threshold
exceeds the probe size, because the filter is skipped.

Pin `join_runtime_filter_min_probe_rows = 0` in those tests, restoring the
behavior they were written against. Observed failing in CI:
`03394_distributed_shuffle_join_with_filter`, `_with_in`, `_with_aggregation`
and `04612_join_runtime_filters_index_analysis_multi_key_anti`
(https://d1k2gkhrlfqv31.cloudfront.net/clickhouse-test-reports-private/json.html?PR=65003&sha=a867fe9e119f88fd563055ae403e90120a26e374&name_0=PR);
the remaining tests assert the same effects with sub-threshold probe sizes.

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [247f4ed]

Summary: ✅


AI Review

Summary

This PR hardens runtime-filter stateless tests against clickhouse-test randomized settings by pinning join_runtime_filter_min_probe_rows where the test contract requires a runtime filter to be built, and by pinning query_plan_optimize_join_order_randomize in the index-analysis cases that assert exact pruning counters. I checked the current diff, the prior review threads, the current CI report, and the sibling runtime-filter tests the author called out; the remaining surface is either pinned, tagged no-random-settings, or intentionally safe.

Final Verdict

Status: ✅ Approve

…ning runtime-filter repros

`04303_join_runtime_filter_query_condition_cache` has a 40-row probe side and
`04327_join_runtime_filter_json` uses single-row subqueries, so under the randomized
`join_runtime_filter_min_probe_rows` the runtime filter is usually not built at all and
the regressions they guard would pass silently. `04401_join_runtime_filter_low_cardinality_nullable`
has the same blind spot when the join tables are swapped and the 150-row side becomes the probe side.
huldarchen pushed a commit to huldarchen/ClickHouse that referenced this pull request Jul 26, 2026
The middle assertion reads the ConstantJoin "Shrinking stored blocks" log
line from system.text_log, filtered by a 60-second recency window
(event_time >= now() - 60). text_log.event_time is the message emission
time, not the flush time, so this window races the duration of the
preceding SYSTEM FLUSH LOGS. On a loaded parallel runner the flush can take
tens of seconds, and the emitted line then falls out of the window, so
count() returns 0 instead of 1.

Measured on four failing runs, all on the parallel sanitizer jobs: the flush
took 65.8s on master sha 693a303, 59.7s on PR ClickHouse#110886 sha 06b7c4b,
101.2s on PR ClickHouse#111790 and 60.9s on PR ClickHouse#111691 sha 19338ec. In each case
the line's age at the assertion was at or just past the 60-second boundary
(66s, 60.1s, 101s, 62s), and for the master and ClickHouse#110886 runs the server log
holds the shrink line for the exact failing query id, so the shrink did
happen and only the time predicate excluded it.

Widen the window to 600s. This is safe because the per-test timeout is 600s,
so a flush slow enough to push the emitted line past a 600s window would trip
the per-test timeout first. The assertion is unchanged and never weakened:
rows are scoped exactly by query_id from system.query_log filtered by
log_comment and current_database = currentDatabase(), and CI assigns every
test run a unique database, so the time predicate only prunes the scan. This
mirrors 00177_memory_bound_merging.sh, which uses now() - 600 on the same
text_log-via-query_id pattern.

Reports:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=693a303c1017477fc39aaa7706af0ec078e13fbc&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%29
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110886&sha=06b7c4b127f65dbc45d7c26d867a4801c0742209&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%29

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…er` repros

`03913_runtime_filter_nullable_tuple` and `04051_runtime_filter_variant_type`
are regression tests for `__applyFilter` returning `Nullable(UInt8)` instead of
`UInt8`, but they relied on the default runtime-filter settings. Under
`clickhouse-test` both `enable_join_runtime_filters` and
`join_runtime_filter_min_probe_rows` are randomized, and their probe sides are
1-3 rows, so the runtime filter could be skipped entirely and the regression
would pass silently.

Pin `enable_join_runtime_filters = 1` and `join_runtime_filter_min_probe_rows = 0`
in both, verified against their references with `clickhouse local`.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The only red in the previous run, `04367_distributed_plan_merge_scatter_multishard` (Stateless tests, arm_binary, parallel), is a timeout unrelated to this PR — this PR only adds `SET` lines to runtime-filter tests and does not touch `04367`. The hang is being fixed in #111762 ("Fix query hang in local execution of distributed plans").

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Merged `master` (351 commits, clean) to refresh CI.

The single red in the previous run, Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel), is unrelated to this PR: the server died with Logical error: Got read request from replica A for unknown stream B, which cascaded into the 02770_async_buffer_ignore error. That is the known parallel-replicas coordinator issue #110518, with a fix in flight in #111689. This PR only adds SET lines to runtime-filter stateless tests and cannot affect the parallel-replicas coordinator.

I also re-ran the coverage sweep against the refreshed master: every test whose reference asserts BuildRuntimeFilter / RuntimeFilterGranules / __applyFilter now either pins join_runtime_filter_min_probe_rows or is tagged no-random-settings. Two tests deliberately need no pin: 04207_top_k_through_join disables runtime filters outright for a deterministic EXPLAIN, and 04357_join_runtime_filter_size_from_hash_table_stats probes 50000 rows, well above the randomizer's ceiling of 10000.

@rienath rienath linked an issue Jul 31, 2026 that may be closed by this pull request
@rienath
rienath added this pull request to the merge queue Jul 31, 2026
Merged via the queue into master with commit b52d957 Jul 31, 2026
178 checks passed
@rienath
rienath deleted the fix-join-runtime-filter-min-probe-rows-flaky-tests branch July 31, 2026 20:56
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 31, 2026
CurtizJ added a commit to CurtizJ/ClickHouse that referenced this pull request Aug 1, 2026
`04653_join_runtime_filters_index_analysis_refiner` asserts that
`RuntimeFilterGranulesConsidered` and `RuntimeFilterGranulesDropped` are
non-zero, but its probe side (`refiner_fact`) has only 2000 rows, while
`clickhouse-test` randomizes `join_runtime_filter_min_probe_rows`
uniformly over 1..10000. Whenever the draw exceeds 2000 no runtime filter
is built at all and both counters collapse to zero, so the test prints
`0 0` instead of `1 1`. All 14 failing runs in CI drew a value above 2000,
the smallest being 2036.

Pin `join_runtime_filter_min_probe_rows = 0`, and also pin
`query_plan_optimize_join_order_randomize = 0` because the asserted
granule-pruning counts depend on which side of the join builds the filter.
These are the same two pins that `04490`, `04611` and `04612` already
carry; the test was modelled on `04611` before they were added there.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112296&sha=381c5ffae13e6bc74d8cdf677b773e55395ec25c&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20flaky%20check%29
Related: ClickHouse#112296
Related: ClickHouse#111691

Co-Authored-By: Claude Opus 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The middle assertion reads the ConstantJoin "Shrinking stored blocks" log
line from system.text_log, filtered by a 60-second recency window
(event_time >= now() - 60). text_log.event_time is the message emission
time, not the flush time, so this window races the duration of the
preceding SYSTEM FLUSH LOGS. On a loaded parallel runner the flush can take
tens of seconds, and the emitted line then falls out of the window, so
count() returns 0 instead of 1.

Measured on four failing runs, all on the parallel sanitizer jobs: the flush
took 65.8s on master sha 693a303, 59.7s on PR ClickHouse#110886 sha 06b7c4b,
101.2s on PR ClickHouse#111790 and 60.9s on PR ClickHouse#111691 sha 19338ec. In each case
the line's age at the assertion was at or just past the 60-second boundary
(66s, 60.1s, 101s, 62s), and for the master and ClickHouse#110886 runs the server log
holds the shrink line for the exact failing query id, so the shrink did
happen and only the time predicate excluded it.

Widen the window to 600s. This is safe because the per-test timeout is 600s,
so a flush slow enough to push the emitted line past a 600s window would trip
the per-test timeout first. The assertion is unchanged and never weakened:
rows are scoped exactly by query_id from system.query_log filtered by
log_comment and current_database = currentDatabase(), and CI assigns every
test run a unique database, so the time predicate only prunes the scan. This
mirrors 00177_memory_bound_merging.sh, which uses now() - 600 on the same
text_log-via-query_id pattern.

Reports:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=693a303c1017477fc39aaa7706af0ec078e13fbc&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%29
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110886&sha=06b7c4b127f65dbc45d7c26d867a4801c0742209&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%29

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.

Flaky test: 04612_join_runtime_filters_index_analysis_multi_key_anti Flaky test: 04611_join_runtime_filters_index_analysis_skip_index

3 participants