Skip to content

Fix flaky 05255_filter_output_evaluated_before_its_filter - #123135

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05255-runtime-filter-skipped-rows
Oct 1, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05255-runtime-filter-skipped-rows

Conversation

@groeneai

@groeneai groeneai commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

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

...

Description

Related: #122143

The last assertion of this test (added in #122143) printed 0 instead of 1 in Stateless tests (arm_binary, parallel). The runner narrowed it to optimize_on_insert = 0, index_granularity = 1493 and min_bytes_for_wide_part = 0 (208/208 failing with them).

The assertion checks RuntimeFilterRowsChecked >= 2000 to prove the runtime filter was applied to t1 (2001 rows) and not to t2 (5 rows). Every t1 row passes the filter, so after the first probe block the filter disables itself (join_runtime_filter_pass_ratio_threshold_for_disabling) and counts later blocks in RuntimeFilterRowsSkipped instead. With the default layout no block is skipped. A level-0 wide part read through FINAL in 1493-row granules arrives in two blocks, and the job's query_log shows 1494 checked plus 507 skipped.

The assertion now sums both counters. The sum was 2001 on all 470 executions of the probe in the failing job. The threshold still separates t1 from the reversed join orientation (5) and from a filter that is never applied (0).

Validation: with the CI layout the old test fails every time and the new one passes. A sweep over index_granularity 1 to 8192, wide and compact parts and optimize_on_insert gives a sum of 2001 in every arm (the old assertion fails 13 of 34). 123 runs with randomized settings pass. Reversing the join, disabling the runtime filter, or raising the threshold to 2002 makes the assertion print 0.


Workflow [PR]
Sync PR [sync-upstream/pr/123135]

Version info

  • Merged into: 26.10.1.1134-master (included in 26.10 and later)

The last assertion checked `RuntimeFilterRowsChecked >= 2000` to prove the
runtime filter was applied to the t1 side (2001 rows) rather than to t2
(5 rows). Every t1 row passes the filter, so after a block whose pass ratio
exceeds join_runtime_filter_pass_ratio_threshold_for_disabling (0.7) the
filter skips later blocks within its budget (rows checked times
join_runtime_filter_blocks_to_skip_before_reenabling) and books them in
RuntimeFilterRowsSkipped, not in RuntimeFilterRowsChecked.

With the default layout t1 arrives in one block, so at most one row is
skipped. With optimize_on_insert = 0 the part has level 0 and FINAL reads it
through the merging path; with a wide part and index_granularity = 1493 that
read yields a 1493-row and a 507-row block, and RowsChecked is 1494. This is
what failed in Stateless tests (arm_binary, parallel) on PR ClickHouse#123121, where
the runner's diagnosis narrowed it to these three settings (208/208 failing).

In the failing job's query_log, Checked + Skipped was 2001 on all 470
executions of the probe, across every layout the runner tried. Sum the two
counters. The threshold still separates t1 from the reversed join
orientation (5) and from a filter that is planted but never applied (0).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Sep 30, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding) plus my own review (2 nits).

# Sev Finding Verdict Evidence / action
1 ❌ With a dropped key set, 2001 skipped and 0 checked rows satisfy the new sum (05255_...sql:83) DISAGREE The #122143 defect is plan-only; FilterTransform.cpp:297-298 evaluates the CAST on every row and a skipped block still calls RuntimeFilter::find (RuntimeFilterLookup.cpp:767-769), so such a filter on t1 still witnesses the bug; never-planted (0) and reversed (5) still fail; unreachable in CI (5 keys, set/bloom size settings not randomized).
2 💡 "both counters are rows the filter was applied to" is loose: skipped rows are not checked AGREE Wording only; the preceding clause explains it. Not blocking.
3 💡 Commit message says t1 "arrives in one block" with the default layout; CI shows 4 blocks, 0 skipped AGREE Conclusion holds; reworded in the PR body. Not blocking.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20260930-201900

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. tests/clickhouse-test --no-random-settings --no-random-merge-tree-settings --client-option allow_merge_tree_settings index_granularity=1493 min_bytes_for_wide_part=0 optimize_on_insert=0 -- 05255_filter_output_evaluated_before_its_filter fails every time with -1 / +0 on the last line, the same diff as CI.
b Root cause explained? Every t1 row passes the runtime filter, so after a block whose pass ratio is above join_runtime_filter_pass_ratio_threshold_for_disabling the filter skips later blocks and counts them in RuntimeFilterRowsSkipped, not RuntimeFilterRowsChecked. A level-0 wide part read through FINAL with index_granularity = 1493 arrives as 1493 + 507 rows, so RowsChecked is 1494 and >= 2000 fails.
c Fix matches root cause? Yes. The assertion's premise (checked rows = rows the filter saw) was wrong. It now sums checked and skipped rows. No setting is pinned, no randomization is removed, and the threshold is unchanged.
d Test intent preserved / new tests added? Yes. The assertion still prints 0 for a reversed join orientation (sum 5) and for a filter that is never applied (sum 0). The other four result lines are unchanged.
e Both directions demonstrated? Yes. The command from (a) fails before the edit and passes after it, on the same binary. The old expression reads 0 on the same query_log row that makes the new one read 1.
f Fix is general across code paths? Sibling runtime-filter tests assert RowsChecked > 0 (the first block is always checked), pin the heuristic off, or already read both counters. None has this premise.
g Fix generalizes across inputs (params/datatypes/wrappers)? A 34-arm sweep over index_granularity (1 to 8192), wide and compact parts, optimize_on_insert and index_granularity_bytes gives a sum of 2001 in every arm. 123 randomized runs and 60 runs with the query cache forced on pass.
h Backward compatible? (maintainer-approved exception only) N/A (test-only change).
i Invariants and contracts preserved? Every row that reaches RuntimeFilter::find is counted in exactly one of RuntimeFilterRowsChecked and RuntimeFilterRowsSkipped. That held on every observed execution, 470 in CI and 34 sweep arms locally.

Session id: cron:clickhouse-impl-slot-4:20260930-200021

@clickhouse-gh

clickhouse-gh Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ab5d329]

Summary: ✅


AI Review

Summary

This PR fixes the flakiness in 05255_filter_output_evaluated_before_its_filter by counting RuntimeFilterRowsSkipped together with RuntimeFilterRowsChecked in the final probe-side assertion. I did not find an unresolved correctness or test-strength regression in that change: the updated predicate still separates the intended probe-side application on t1 from the reversed-side (5) and never-applied (0) cases, and the key_set_dropped path does not make the test vacuous because the original bug is exercised by the presence of the __applyFilter/FilterTransform step even when the filter returns an all-true block mask.

Final Verdict
  • Status: ✅ Approve

@alexey-milovidov alexey-milovidov self-assigned this Oct 1, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 1, 2026
Merged via the queue into ClickHouse:master with commit 7307c44 Oct 1, 2026
149 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 1, 2026
@clickhouse-gh clickhouse-gh Bot added comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect 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.

3 participants