Skip to content

Decline automatic parallel replicas when a set cannot be paired - #126141

Merged
nickitat merged 2 commits into
masterfrom
set-transplant-bug
Oct 19, 2026
Merged

nickitat merged 2 commits into
masterfrom
set-transplant-bug

Conversation

@nickitat

@nickitat nickitat commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix a LOGICAL_ERROR when automatic parallel replicas cannot match prepared sets between the single-node and replica plans, including queries using query_plan_convert_join_to_in. These queries now retain the single-node plan.


Closes: #124322


Workflow [PR]
Sync PR [sync-upstream/pr/126141]

Version info

  • Merged into: 26.11.1.212-master (included in 26.11 and later)
  • Backported to: 26.10.2.32

nickitat and others added 2 commits October 15, 2026 21:54
When automatic parallel replicas switches a query, `moveSetsFromLocalPlanToReplicasPlan` hands the
sets the single-node plan has already prepared to the parallel-replicas plan, pairing them by hash.
Nothing guarantees that the two plans hash a set alike, and a set without a counterpart failed the
query with the `LOGICAL_ERROR` "Cannot find a matching set in the map of sets from single-replica
plan" (aborting debug and sanitizer builds). Two known causes:

- The parallel-replicas plan is built from the query tree shipped to the replicas, where
  `ReplaceLongConstWithScalarVisitor` replaces constants longer than `optimize_const_name_size`
  with `__getScalar` calls, also inside an `IN` subquery, which changes the subquery's tree hash.
- `convertJoinToIn` keys the set it makes by a random UUID (issue 124322).

Check that every set has a counterpart before moving any, and keep the single-node plan otherwise.

Closes: #124322

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	src/Processors/QueryPlan/Optimizations/considerEnablingParallelReplicas.cpp
@clickhouse-gh

clickhouse-gh Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [dd81fe5]

Summary: ✅


AI Review

Summary

The PR checks that every required set can be paired before transferring ownership, retaining the single-node plan when pairing fails. This avoids the LOGICAL_ERROR caused by differing set hashes under automatic parallel replicas. The implementation looks sound, and the new regression test passes in Fast test. Only a changelog nit remains.

PR Metadata

The Bug Fix category matches the change. A user-readable changelog entry is required; the current todo placeholder does not satisfy that requirement.

Findings

💡 Nits

  • PR description: Replace todo with: “Fix a LOGICAL_ERROR when automatic parallel replicas cannot match prepared sets between the single-node and replica plans, including queries using query_plan_convert_join_to_in. These queries now retain the single-node plan.”
Final Verdict

Status: ✅ Approve. Complete the changelog entry before merging.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 15, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). label Oct 15, 2026
@nickitat
nickitat marked this pull request as ready for review October 16, 2026 10:11
@nickitat
nickitat requested a review from devcrafter October 16, 2026 10:28
@devcrafter devcrafter self-assigned this Oct 16, 2026

@devcrafter devcrafter left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ...

@nickitat Do we have such issue with plan-base parallel replicas?

@nickitat

Copy link
Copy Markdown
Member Author

LGTM ...

@nickitat Do we have such issue with plan-base parallel replicas?

no, afaict

@nickitat
nickitat added this pull request to the merge queue Oct 19, 2026
Merged via the queue into master with commit 10e33cb Oct 19, 2026
179 checks passed
@nickitat
nickitat deleted the set-transplant-bug branch October 19, 2026 17:12
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 19, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 19, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 19, 2026
PedroTadim added a commit that referenced this pull request Oct 20, 2026
Backport #126141 to 26.10: Decline automatic parallel replicas when a set cannot be paired
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.10-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto parallel replicas throws LOGICAL_ERROR on JOIN rewritten to IN

5 participants