Repository navigation
Fix logical error in automatic parallel replicas with min_number_of_rows_per_replica - #109011
Conversation
…ows_per_replica
considerEnablingParallelReplicas() asserted that the local parallel-replicas
reading step had no index analysis yet before transplanting the single-replica
analysis into it:
chassert(local_replica_plan_reading_step->getAnalyzedResult() == nullptr);
This holds when parallel_replicas_min_number_of_rows_per_replica == 0, but not
otherwise: with that setting > 0, the planner
(PlannerJoinTree.cpp, canUseParallelReplicasOnInitiator branch) runs index
analysis on the reading step to estimate how many replicas to use, and that same
step is then moved into the parallel-replicas plan. So it already carries an
analysis by the time automatic parallel replicas wants to reuse the
single-replica one, and the assertion aborts the server in debug and sanitizer
builds.
The pre-existing analysis is legitimate, so instead of asserting we simply
overwrite it with the single-replica analysis, which is exactly what the
min_number_of_rows_per_replica == 0 path already does. Both analyses are
selectRangesToRead() over the same table and query, so the result is identical.
Reproduced by an aggregation with automatic_parallel_replicas_mode = 1 and
parallel_replicas_min_number_of_rows_per_replica > 0, once the dataflow
statistics cache is populated. The default of the setting is 0, which is why the
existing test 04034_autopr_dataflow_cache_reuse_between_different_queries does not
hit it; CI randomizes the setting, which is how the fuzzer found it.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-3:20260701-034200 |
|
cc @nickitat @KochetovNicolai — could you review this? It fixes the auto-parallel-replicas |
|
Workflow [PR], commit [4531517] Summary: ✅
AI ReviewSummaryThis PR fixes an invalid Missing context / blind spots
Final Verdict✅ No findings to post inline. The change looks reasonable pending completion of CI. |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 5/5 (100.00%) · Uncovered code |
CI finish ledger — 4531517CI is fully finished (Finish Workflow succeeded; only
Session id: cron:our-pr-ci-monitor:20260701-093000 |
|
Fixing PR for the 00612_pk_in_tuple_perf transient flake: #109039 |
|
Fixing PR for the Upgrade-check |
|
Correction/split on the Upgrade check (amd_release) error-leak line: it had two independent benign leftover-state signatures. The |
CI finish ledger — 4531517Every failure below has an owner. Only
No PR-caused failure on this SHA. #109011's diff only drops an over-strict Session id: cron:our-pr-ci-monitor:20260703-013000 |
04fe85d
…s-analyzed-result-assertion Fix logical error in automatic parallel replicas with min_number_of_rows_per_replica
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a
LOGICAL_ERROR(local_replica_plan_reading_step->getAnalyzedResult() == nullptr) in the automatic parallel replicas planner that could occur whenautomatic_parallel_replicas_modeis enabled together withparallel_replicas_min_number_of_rows_per_replicagreater than 0.Description
considerEnablingParallelReplicas()asserted that the local parallel-replicas reading step carried no index analysis yet before transplanting the single-replica analysis into it:This holds when
parallel_replicas_min_number_of_rows_per_replica == 0, but not otherwise. With that setting greater than 0, the planner (PlannerJoinTree.cpp,canUseParallelReplicasOnInitiator()branch) runs index analysis on the reading step to estimate how many replicas to use, and that same step is then moved into the parallel-replicas plan. So it already carries an analysis by the time automatic parallel replicas wants to reuse the single-replica one, and the assertion fails. This is an exception that is handled in release builds, but it aborts the server in debug and sanitizer builds.The pre-existing analysis is legitimate, so instead of asserting we overwrite it with the single-replica analysis, which is exactly what the
parallel_replicas_min_number_of_rows_per_replica == 0path already does. Both analyses areselectRangesToRead()over the same table and query, so the result is identical.Reproduction (deterministic on a debug build): an aggregation with
automatic_parallel_replicas_mode = 1andparallel_replicas_min_number_of_rows_per_replica > 0, run twice so the dataflow statistics cache is populated. The default of the setting is 0, which is why the existing test04034_autopr_dataflow_cache_reuse_between_different_queriesdoes not hit it; CI randomizes the setting (see #71028), which is how the fuzzer found it.The assertion was reported by the AST fuzzer (
AST fuzzer (amd_debug), STID 2508-5243). Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100752&sha=7af449dad33f6e6f34c5e583129fe1652fd54436&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%29 . It is a pre-existing planner bug, unrelated to #100752 where it happened to surface; over 60 days it also appeared under #71028, #104513 and #106073.A regression test
04034_autopr_min_rows_per_replica_reuses_index_analysisis added that pinsparallel_replicas_min_number_of_rows_per_replicato deterministically exercise the fixed path and asserts that automatic parallel replicas still engages.Version info
26.7.1.522(included in26.7and later)