Repository navigation
Conversation
A session temporary table exists only on the server that created it, and `RemoteQueryExecutor` sends only the `Memory` ones to the replicas as external tables. Parallel replicas still planned reads that a replica had to serve from such a table: the table read itself (05233 under `optimize_trivial_count_query = 0`), the custom-key read, a JOIN or an `IN` subquery executed by the followers, the materialization of a `GLOBAL IN` / `GLOBAL JOIN` side, and a temporary view unwrapped by `parallel_replicas_allow_view_over_mergetree`. With the local plan every replica logged `There is no table ... on server` and the initiator read alone; without it the query failed with `ALL_CONNECTION_TRIES_FAILED` or `UNKNOWN_TABLE` (ClickHouse#74229). `DisableParallelReplicasPass` already turns parallel replicas off for a query shape they cannot serve (correlated subqueries). It now also does so when the query reads a temporary table that is not `Memory` (a temporary view only when it would be unwrapped). The rule is evaluated for the task-based and the custom-key modes. The five tests blacklisted for this bug in the ParallelReplicas configuration pass again and are removed from the blacklist. Closes ClickHouse#74229 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y SETTINGS or a view A subquery with its own `SETTINGS` clause is planned with its own context, so it could enable parallel replicas while the root query did not, and the replicas were then asked to read a temporary table they never received. The finder in `DisableParallelReplicasPass` now always runs and records whether any query or union scope can use the task-based or custom-key mode. With `parallel_replicas_allow_view_over_mergetree` the planner unwrapped a view (a stored view or `view(...)`) whose body reads a temporary `MergeTree` table, because the eligibility check had no temporary-table rule, and shipped the view to replicas that cannot resolve its body. A temporary table is no longer an eligible source there, so the view body is planned locally, where the pass sees the temporary table. 05345 gains a line for each case and an `EXPLAIN` control proving a `Memory` temporary table still gets a parallel-replicas read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the pass doc comment to one line and drop the clause of the finder's comment that restated what the code does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; round 1: 3 findings, round 2 delta: 1 finding) plus my own cold review of both rounds.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261009-191100 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261009-170000 |
|
Workflow [PR], commit [67fffd0] Summary: ✅
AI ReviewSummaryThis PR disables task-based and custom-key parallel replicas when an analyzed query reads a temporary table that cannot be sent to replicas, while preserving Final VerdictStatus: ✅ Approve |
CI finish ledger - 24923e6Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261010-023009 |
…plicas-temporary-table Resolve the conflict in `DisableParallelReplicasPass.cpp` with the dry run that master added to `DisableParallelReplicasVisitor` for `disablesParallelReplicasInWholeTree`: keep master's visitor and give it back the initial latch from `FindTemporaryTableNotSentToReplicasVisitor`, renaming `is_correlated` to `disable` as before, since the latch is no longer only about a correlated subquery. The dry run starts unlatched. `disablesParallelReplicasInWholeTree` may only answer true when the pass turns parallel replicas off everywhere, so missing the temporary-table case just builds the probe plan as on master. A query that reads only a temporary table is already rejected by `canQueryPossiblyUseParallelReplicas` through `isStorageEligibleForParallelReplicas`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since ClickHouse#129223 plan-based parallel replicas keep the read of a temporary table on the initiator (`mergeTreeReadCanBeShipped`) and still distribute the other subtrees of the query, e.g. an aggregation over a regular table joined with a temporary table. Turning parallel replicas off for the whole query in `DisableParallelReplicasPass` took that away and broke `05497_pr_plan_based_temporary_table_read_stays_local` (10/10 runs). The finder now fires only for task-based and custom-key parallel replicas, the modes that send the query to the replicas as is. `05345_parallel_replicas_temporary_table` covers the task-based mode, so it sets `parallel_replicas_plan_based = 0` and keeps its result in the plan-based CI configuration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Master's .clang-tidy enables modernize-use-nodiscard, which failed Build (arm_tidy, 3/4) on this const getter after the master merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units11 translation units recompiled, 34 s compile time in total, 11 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.06 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
Closes: #74229
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed queries that read a temporary table with an engine other than
Memory(for exampleMergeTree) with parallel replicas enabled: they failed withALL_CONNECTION_TRIES_FAILEDorUNKNOWN_TABLE, or loggedThere is no table ... on serverfor every replica. Such queries now run without parallel replicas. Closes #74229.Description
On 26.8.18.2 and 26.3.42.3,
SELECT sum(a) FROM tfor a temporaryMergeTreetabletwith parallel replicas enabled (settings as in the new test) andparallel_replicas_local_plan = 0fails withALL_CONNECTION_TRIES_FAILED. With the local plan the result is right, but each replica logsThere is no table ... on server, so05233_constraint_graph_negated_ordered_comparisonfails in the ParallelReplicas job whenoptimize_trivial_count_query = 0is drawn (example, 7 PRs since 2026-10-04).Only
Memorytemporary tables are sent to the replicas (RemoteQueryExecutor), yet a replica can be made to read another one: the table itself, a custom-key read, a JOIN orINsubquery the followers execute, aGLOBAL IN/GLOBAL JOINmaterialization, or a temporary view unwrapped byparallel_replicas_allow_view_over_mergetree.DisableParallelReplicasPass, which already does this for correlated subqueries, now disables parallel replicas for the whole query that reads such a table, also when only a subquery's ownSETTINGSenables them. A view is no longer unwrapped onto such a table.Memorytemporary tables and plan-based parallel replicas are not affected; the latter keep the read of a temporary table on the initiator since #129223. Not covered:joinGeton a temporaryJointable, and the body of a view orview()that a follower executes.Validation: each query of the new test reading a non-
Memorytemporary table fails on master and passes with the fix; theMemorycontrol still plans a parallel-replicas read. 05233 withoptimize_trivial_count_query = 0goes from 20/20 FAIL to 20/20 OK in the ParallelReplicas job. Five tests blacklisted there for this bug pass again and leaveparallel_replicas_blacklist.txt.Related: #124934 (pins the 05233 query).
Workflow [PR]
Sync PR [sync-upstream/pr/124987]