Repository navigation
Pin join-plan randomization in the AutoPR join tests - #113908
Conversation
Under randomized settings, `query_plan_optimize_join_order_randomize` produces different cardinality estimates in the single-replica and the candidate parallel-replicas plan builds (and can flip the `join_runtime_filter_min_probe_rows` threshold in only one of them), so the plan shapes diverge, `findCorrespondingNodeInSingleNodePlan` finds no matching hash, and AutoPR skips the instrumentation or declines to apply (fail-closed) - the tests then report 0 instead of the expected value. Pin `query_plan_optimize_join_order_randomize = 0` and `enable_join_runtime_filters = 0`, as `04341_autopr_mode1_apply_join` does in #113904. Seen on #113412: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113412&sha=d882b451a59bc6e5b1baf8b21798757e9b1c122b&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20parallel%2C%203%2F3%29 Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [76c3008] Summary: ✅ AI ReviewSummaryThis PR pins Final Verdict✅ No findings. |
Address the AI review: with the companion #113904 still open, this branch alone left one AutoPR join test exposed to the same randomized-plan divergence. Apply the identical pin from that PR (byte-for-byte, so both PRs merge cleanly in either order): pin query_plan_optimize_join_order_randomize = 0 and keep runtime filters enabled with join_runtime_filter_min_probe_rows pinned, since this test is the only mode=1 APPLY coverage for the RIGHT JOIN plan shape with BuildRuntimeFilterStep present. Co-Authored-By: Claude Fable 5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113908&sha=a3f062cd51ebc35bba029e92980560873b2f4b0e&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. The |
|
@alexey-milovidov Investigated. Confirmed unrelated to this PR, and no fix is in progress yet, so I am authoring one and will link it here. STID 2781-51e9. The exact message from Same signature and same stack as #98898: The shape of the defect is visible in the part name. Breadth from CIDB: 2 occurrences in 90 days, and one of them is on master rather than a PR, so nothing about this PR is implicated.
Note the existing guards do not cover this. |
|
@alexey-milovidov Fix is up: #113998 Root cause, confirmed locally with a deterministic repro rather than inferred from the report: only a merge of patch parts can produce a patch whose source data-version range spans a mutation version, because The fix takes the pending versions from the replication queue instead, since a queued Two things I deliberately did not do, both stated in the PR. It does not repair a patch that already spans a version on disk, so a table already in that state stays stuck; that needs per-row Breadth from CIDB over 90 days: exactly 2 occurrences of this message, one of them on master, so it is a trunk defect and rare rather than PR-caused. |
|
🕵 Both stress-test failures on 86dfbcf are unrelated to this PR (which only pins settings in five stateless tests); I have merged
@groeneai, investigate failure 2 and provide a fix in a separate PR (if a fix is already in progress, link it here). A starting hint: the |
|
🕵 Filed #114000 to track the |
|
Confirmed, and not caused by this PR (its diff is five The root cause is not the So no LIMIT is needed. My reproducer has none and leaks 30 allocations on a master ASAN build: CREATE TABLE t (parent_key Int, child_key Int, value Float64) ENGINE = MergeTree ORDER BY parent_key;
INSERT INTO t SELECT number % 10, number % 3, number FROM numbers(1000);
SELECT parent_key, child_key, quantileDD(0.01, 0.5)(value) FROM t GROUP BY parent_key, child_key
SETTINGS max_threads = 1, optimize_aggregation_in_order = 1;Controls are clean: On the counts: 48 objects is one of the seven This has been latent since 3931dbd, which added the mode and all the |
|
The fix is up: #114010 ( As posted earlier, the mechanism is the unconditional producer at This CI failure is not caused by this PR, which changes only |
|
🕵 All four stress-test reds on 0b1f9e0 are unrelated to this PR (its diff is still only five
The AI review verdict is ✅ and there are no unresolved review threads, so this is ready for a human to merge; the stress reds will clear once the fixes above land. |
|
I propose to use the default settings for runtime filters: diff --git a/tests/queries/0_stateless/04305_autopr_output_bytes_estimation_join.sql b/tests/queries/0_stateless/04305_autopr_output_bytes_estimation_join.sql
index 94f04b2dc2e88..85f00ad81b585 100644
--- a/tests/queries/0_stateless/04305_autopr_output_bytes_estimation_join.sql
+++ b/tests/queries/0_stateless/04305_autopr_output_bytes_estimation_join.sql
@@ -11,8 +11,9 @@ SET query_plan_join_swap_table='false';
-- statistics (query_plan_optimize_join_order_randomize) produce different cardinality estimates in
-- the two plan builds, which can flip the runtime filter's join_runtime_filter_min_probe_rows
-- threshold in only one of them; the plans then diverge, AutoPR skips the instrumentation
--- (fail-closed), and output_bytes stays 0.
-SET query_plan_optimize_join_order_randomize=0, enable_join_runtime_filters=0;
+-- (fail-closed), and output_bytes stays 0. Pin the runtime filter settings to their defaults
+-- instead of disabling them, so the default code path stays covered.
+SET query_plan_optimize_join_order_randomize=0, enable_join_runtime_filters=1, join_runtime_filter_min_probe_rows=1000;
SET max_bytes_before_external_group_by=0, max_bytes_ratio_before_external_group_by=0;
SET max_bytes_before_external_sort=0, max_bytes_ratio_before_external_sort=0;
diff --git a/tests/queries/0_stateless/04340_autopr_input_bytes_estimation_join.sql b/tests/queries/0_stateless/04340_autopr_input_bytes_estimation_join.sql
index 1e837eae8259c..5d6d80e3501ab 100644
--- a/tests/queries/0_stateless/04340_autopr_input_bytes_estimation_join.sql
+++ b/tests/queries/0_stateless/04340_autopr_input_bytes_estimation_join.sql
@@ -22,8 +22,9 @@ SET query_plan_join_swap_table='false';
-- statistics (query_plan_optimize_join_order_randomize) produce different cardinality estimates in
-- the two plan builds (and can flip the join_runtime_filter_min_probe_rows threshold in only one
-- of them); the plans then diverge, AutoPR skips the instrumentation (fail-closed), and
--- input_bytes stays 0.
-SET query_plan_optimize_join_order_randomize=0, enable_join_runtime_filters=0;
+-- input_bytes stays 0. Pin the runtime filter settings to their defaults instead of disabling
+-- them, so the default code path stays covered.
+SET query_plan_optimize_join_order_randomize=0, enable_join_runtime_filters=1, join_runtime_filter_min_probe_rows=1000;
-- Reading aggregation states / external sort spills from disk would inflate `ReadCompressedBytes`.
SET max_bytes_before_external_group_by=0, max_bytes_ratio_before_external_group_by=0;
diff --git a/tests/queries/0_stateless/04342_autopr_join_apply_distinct_preanalyzed.sql b/tests/queries/0_stateless/04342_autopr_join_apply_distinct_preanalyzed.sql
index ea3af46be05aa..57f2485c7c6a1 100644
--- a/tests/queries/0_stateless/04342_autopr_join_apply_distinct_preanalyzed.sql
+++ b/tests/queries/0_stateless/04342_autopr_join_apply_distinct_preanalyzed.sql
@@ -33,8 +33,9 @@ SET query_plan_join_swap_table='false';
-- Keep the plan identical between the collect and apply runs: randomized join-order statistics
-- (query_plan_optimize_join_order_randomize) produce different cardinality estimates in different
-- plan builds (and can flip the join_runtime_filter_min_probe_rows threshold in only one of them),
--- so AutoPR declines to apply (fail-closed) and result_ok stays 0.
-SET query_plan_optimize_join_order_randomize=0, enable_join_runtime_filters=0;
+-- so AutoPR declines to apply (fail-closed) and result_ok stays 0. Pin the runtime filter settings
+-- to their defaults instead of disabling them, so the default code path stays covered.
+SET query_plan_optimize_join_order_randomize=0, enable_join_runtime_filters=1, join_runtime_filter_min_probe_rows=1000;
SET enable_analyzer=1;
SET max_threads=4, max_block_size=128;
SET automatic_parallel_replicas_min_bytes_per_replica=0, merge_tree_min_bytes_per_task_for_remote_reading=0;
diff --git a/tests/queries/0_stateless/04655_autopr_join_any_take_last_row_cache_key.sql b/tests/queries/0_stateless/04655_autopr_join_any_take_last_row_cache_key.sql
index 39ace77f45291..062b3a7b325a5 100644
--- a/tests/queries/0_stateless/04655_autopr_join_any_take_last_row_cache_key.sql
+++ b/tests/queries/0_stateless/04655_autopr_join_any_take_last_row_cache_key.sql
@@ -19,8 +19,10 @@ SET query_plan_join_swap_table='false';
-- Keep the plan identical between the collect and apply runs: randomized join-order statistics
-- (query_plan_optimize_join_order_randomize) produce different cardinality estimates in different
-- plan builds (and can flip the join_runtime_filter_min_probe_rows threshold in only one of them),
--- so AutoPR skips the statistics collection (fail-closed) and stats_collected stays 0.
-SET query_plan_optimize_join_order_randomize=0, enable_join_runtime_filters=0;
+-- so AutoPR skips the statistics collection (fail-closed) and stats_collected stays 0. Pin the
+-- runtime filter settings to their defaults instead of disabling them, so the default code path
+-- stays covered.
+SET query_plan_optimize_join_order_randomize=0, enable_join_runtime_filters=1, join_runtime_filter_min_probe_rows=1000;
SET automatic_parallel_replicas_min_bytes_per_replica=0;
SET merge_tree_min_bytes_per_task_for_remote_reading=0;It works per my local measurements: |
…sabling Per nickitat's suggestion on the PR: keep `enable_join_runtime_filters = 1` and `join_runtime_filter_min_probe_rows = 1000` (the defaults) pinned instead of disabling the runtime filters, so the default code path stays covered. With `query_plan_optimize_join_order_randomize = 0` both plan builds draw the same cardinality estimates, so a pinned threshold decides identically in both. In `04340` the pin is merged into the block that came from master (which already pinned `enable_join_runtime_filters = 1`) instead of duplicating it. Verified locally: all five AutoPR join tests pass 5/5 runs with settings randomization enabled. Co-Authored-By: Claude Fable 5 <[email protected]>
|
🕵 Applied your suggestion in 76c3008 — thanks! All four tests now pin |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
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 units6 translation units recompiled, 5 s compile time in total, 6 of them have a recent master baseline. |
|
🕵 Triage of the four stress reds on 76c3008 (2026-08-11 run): all four are the known fleet-wide storms, unrelated to this PR (it only pins settings in four stateless
Both storms are fixed by the open PR #113397, not yet merged, so re-merging master does not clear them. Everything else is green, the AI review verdict is ✅, and there are no unresolved review threads — ready for a human merge decision once the storm fix lands. |
Related: #113904
Related: #113412
Related: #106073
Companion to #113904 (merged 2026-08-10); this covers the remaining four AutoPR join tests added in #106073, all flaking since 2026-08-07 (
04305on 7 PRs,04340/04342/04655_autopr_join_any_take_last_row_cache_keyalso on master runs).Under randomized settings,
query_plan_optimize_join_order_randomizeproduces different cardinality estimates in the single-replica and the candidate parallel-replicas plan builds. Reproduced locally with the CI culprit settings (join_runtime_filter_min_probe_rows=9325,query_plan_optimize_join_order_randomize=306668) against a real server with aparallel_replicascluster: the single-replica plan estimated a join cardinality of 8957322 and installed the join runtime filter, while the candidate replicas plan estimated 8755 (below the randomizedjoin_runtime_filter_min_probe_rowsthreshold) and did not, so the plan shapes diverged,findCorrespondingNodeInSingleNodePlanloggedCannot find step with matching hash in single-node plan, and AutoPR skipped the instrumentation (fail-closed) — the test then reportsoutput_bytes = 0.04340reproduces withquery_plan_optimize_join_order_randomizealone (a diverging join order, no runtime filter needed).Pin
query_plan_optimize_join_order_randomize = 0and, per review feedback, pin the runtime-filter settings to their defaults (enable_join_runtime_filters = 1,join_runtime_filter_min_probe_rows = 1000) instead of disabling them, so the default code path stays covered — with the randomization off, both plan builds draw the same cardinality estimates and a pinned threshold decides identically in both. This matches the pin04341_autopr_mode1_apply_joingot in #113904. Verified locally:04305and04340fail with the culprit settings before the pin; after it, all five AutoPR join tests pass 100/100 runs with settings randomization enabled (see the measurement in the comments) and 25/25 in a follow-up run of the final revision.Seen on #113412: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113412&sha=d882b451a59bc6e5b1baf8b21798757e9b1c122b&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20parallel%2C%203%2F3%29
Changelog category (leave one):
Version info
26.8.1.1266(included in26.8and later)