Skip to content

Fix flaky test 04001_join_reorder_through_expression under randomized join order - #109499

Merged
Algunenano merged 1 commit into
masterfrom
fix-04001-join-reorder-randomize
Jul 6, 2026
Merged

Algunenano merged 1 commit into
masterfrom
fix-04001-join-reorder-randomize

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

The stateless test 04001_join_reorder_through_expression asserts a specific join tree via EXPLAIN PLAN keep_logical_steps = 1. The CI-randomized setting query_plan_optimize_join_order_randomize injects random cardinalities/NDVs into the join-order cost model when non-zero, so the optimizer picks a different (still valid) tree and the EXPLAIN output no longer matches the reference.

The randomized-settings diagnosis pins the culprit exactly:

Culprit settings: --query_plan_optimize_join_order_randomize 587125
Step 2: Re-running without randomized settings ...
  Runs: 56, Failed: 0, Passed: 56, Other: 0
Result: Passes without randomization. Confirmed: the failure is caused by randomized settings.

It reproduces 100% under the randomizer and fails reproducibly on master across every architecture (arm_binary, amd_debug, amd_tsan, amd_asan_ubsan, amd_msan, …) — see the PR=0 history for this test on play.clickhouse.com.

The fix pins query_plan_optimize_join_order_randomize = 0 in the test, matching the existing pattern in sibling join-order tests such as 04277_parallel_replicas_join_dp_reorder and the 03960_join_order_dphyp_* family, which disable the same randomization because they also check a deterministic EXPLAIN join tree.

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

...

🤖 Generated with Claude Code

Version info

  • Merged into: 26.7.1.560 (included in 26.7 and later)

… join order

The test asserts a specific join tree via `EXPLAIN PLAN keep_logical_steps = 1`,
but the CI-randomized setting `query_plan_optimize_join_order_randomize` injects
random cardinalities/NDVs into the join-order cost model when non-zero, producing
a different (still valid) tree and a reference mismatch. The randomized-settings
diagnosis reproduces it 100% (`--query_plan_optimize_join_order_randomize 587125`)
and confirms it passes without randomization. It fails reproducibly on `master`
across every architecture (see PR=0 history on play.clickhouse.com).

Pin `query_plan_optimize_join_order_randomize = 0` in the test, matching the
existing pattern in sibling join-order tests (`04277_parallel_replicas_join_dp_reorder`,
`03960_join_order_dphyp_*`).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4410afb]

Summary: ✅


AI Review

Summary

This PR pins query_plan_optimize_join_order_randomize = 0 in 04001_join_reorder_through_expression, which is an EXPLAIN PLAN keep_logical_steps = 1 test that asserts a specific logical join tree. That follows the existing pattern in sibling join-order tests that already disable the same randomizer for deterministic EXPLAIN output, and it does not weaken the actual behavior under test. I did not find a correctness, coverage, or PR-metadata issue that warrants an inline comment.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 6, 2026
@Algunenano Algunenano self-assigned this Jul 6, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.88% 85.89% +0.02%
Functions 91.47% 91.47% +0.00%
Branches 78.42% 78.47% +0.04%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 118 line(s), 4 function(s) across 48 file(s) · Details

Top files
  • src/Functions/catboostEvaluate.cpp: 13 line(s), 1 function(s)
  • src/Functions/FunctionsExternalDictionaries.h: 8 line(s)
  • src/Functions/FunctionsBitmap.h: 6 line(s)
  • src/Server/KeeperTCPHandler.cpp: 6 line(s)
  • src/AggregateFunctions/AggregateFunctionQuantileExactInclusive.cpp: 5 line(s)

Full report

@Algunenano
Algunenano added this pull request to the merge queue Jul 6, 2026
Merged via the queue into master with commit c777849 Jul 6, 2026
175 checks passed
@Algunenano
Algunenano deleted the fix-04001-join-reorder-randomize branch July 6, 2026 17:32
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 6, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…eorder-randomize

Fix flaky test 04001_join_reorder_through_expression under randomized join order
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