Skip to content

Pin plan-shape settings in 04340_autopr_input_bytes_estimation_join - #114021

Merged
alexey-milovidov merged 3 commits into
masterfrom
fix/04340-pin-plan-shape-settings
Aug 10, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
fix/04340-pin-plan-shape-settings

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 9, 2026 •

Copy link
Copy Markdown
Member

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

Fix flakiness of 04340_autopr_input_bytes_estimation_join under the settings randomizer.

The test asserts that the input-byte autopr statistics instrument the parallelized side of a JOIN, comparing RuntimeDataflowStatisticsInputBytes against ReadCompressedBytes with a 3x tolerance.

Root cause (confirmed from the failing run's server log): under query_plan_optimize_join_order_randomize (a test-only fuzzing setting) the join-order optimizer draws randomized table statistics on every plan build, and getRandomizedStats mixes the seed with the per-build input labels, which differ between the single-replica plan and the parallel-replicas candidate plan (t1 vs ij_big AS t1). The two plans can therefore pick different join orders, the plan-hash match in considerEnablingParallelReplicas fails ("Cannot find step with matching hash in single-node plan"), no reading step gets instrumented, and the recorded input_bytes stays 0, tripping the guard. Every failing run of this test in CIDB over the last 60 days (excluding two PR-specific regressions) had this setting active.

Pin query_plan_optimize_join_order_randomize = 0, and pin enable_join_runtime_filters = 1 (its default) so the test deterministically keeps covering the runtime-filtered JOIN shape in the instrumentation path — per review feedback, this coverage must not be randomized off.

Example failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96844&sha=6667b70e76f4f8cf056f3aff7aa43b05072521f3&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20flaky%20check%29

Related: #96844

Version info

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

The test asserts that the input-byte autopr statistics instrument the
parallelized side of a JOIN, comparing `RuntimeDataflowStatisticsInputBytes`
against `ReadCompressedBytes`. Under the settings randomizer,
`query_plan_optimize_join_order_randomize` and the runtime join filters
(`enable_join_runtime_filters` with a low `join_runtime_filter_min_probe_rows`)
restructure the plan around the JOIN, so `findReadingStep` does not instrument
the parallelized reading step and the recorded `input_bytes` stays 0, tripping
the guard. Pin both settings off - the test checks which side of the JOIN is
instrumented, not the join-order optimizer.

Example failure (flaky check in another PR, culprit settings pinned by the
harness minimization): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96844&sha=6667b70e76f4f8cf056f3aff7aa43b05072521f3&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20flaky%20check%29
PR: #96844
@clickhouse-gh

clickhouse-gh Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ba009c7]

Summary: ✅


AI Review

Summary

This PR pins query_plan_optimize_join_order_randomize = 0 and keeps enable_join_runtime_filters = 1 in 04340_autopr_input_bytes_estimation_join so the settings randomizer no longer lets the single-node and parallel-replicas plan builds diverge. I reviewed the current test, the relevant considerEnablingParallelReplicas / joinRuntimeFilter paths, and the prior discussion; I did not find remaining correctness or coverage gaps in the updated hunk.

Final Verdict

✅ No remaining findings.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 9, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing ba009c76d with master aa1a69b2a (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 690.92 MiB 687.89 MiB -3.03 MiB (-0.44%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

6 translation units recompiled, 3 s compile time in total, 6 of them have a recent master baseline.

Job report

… the real culprit

The AI review correctly objected to pinning `enable_join_runtime_filters = 0`:
it would drop coverage of the default-on runtime-filtered `JOIN` shape. Investigation
of the failing runs' server logs shows the runtime filters were a red herring:

- Every failing run in CIDB (10 of 10 in the last 60 days, excluding two
  PR-specific regressions) had `query_plan_optimize_join_order_randomize` active,
  while `enable_join_runtime_filters` was merely at its default.
- The failing run's server log shows the actual mechanism:
  `optimizeJoin` draws randomized statistics separately for the single-replica
  plan and the parallel-replicas candidate plan (`getRandomizedStats` mixes the
  seed with the per-build input labels, which differ between the two builds:
  `t1` vs `ij_big AS t1`), the plans diverge, and
  `considerEnablingParallelReplicas` logs "Cannot find step with matching hash
  in single-node plan" -- no reading step is instrumented and `input_bytes`
  stays 0.
- Locally, the test passes with `enable_join_runtime_filters = 1` under the
  failing run's full randomized-settings set, for all three join kinds.

So keep `query_plan_optimize_join_order_randomize = 0` (a test-only fuzzing
setting, with the corrected explanation) and pin `enable_join_runtime_filters = 1`
instead of 0, making the test deterministic regression coverage for the
runtime-filtered `JOIN` shape.

Example failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96844&sha=6667b70e76f4f8cf056f3aff7aa43b05072521f3&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20flaky%20check%29
Related: #96844

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 CI triage for the reds on c85e27af:

The AI review's requested change is addressed in f0f55473 — see the thread reply for the root-cause evidence.

…shape-settings

Pull in the fix for the flaky `04267_ttl_drop_merge_no_data_read` (#114050), which was the only CI red on this test-only pull request.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 CI triage for the single red on f0f55473:

  • Stateless tests (amd_msan, WasmEdge, parallel, 1/3) — 04267_ttl_drop_merge_no_data_read ("result differs with reference"): unrelated to this test-only change to 04340_autopr_input_bytes_estimation_join. It is the known empty-part race in that test, and the fix has already merged into master: Fix flaky test 04267_ttl_drop_merge_no_data_read #114050

Merged master (ba009c76d3dc) so the fix is pulled in; the diff against master is unchanged (the same 12-line hunk in the test). The AI review verdict on f0f55473 is "No remaining findings" and there are no unresolved review threads.

@alexey-milovidov alexey-milovidov left a comment

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.

Ok.

@alexey-milovidov alexey-milovidov self-assigned this Aug 10, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 10, 2026
@nickitat

Copy link
Copy Markdown
Member

lgtm, thanks.

Merged via the queue into master with commit c893898 Aug 10, 2026
181 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix/04340-pin-plan-shape-settings branch August 10, 2026 13:04
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 10, 2026
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.

3 participants