Skip to content

Plan-based parallel replicas: keep reads of UNIQUE KEY tables local - #133744

Merged
devcrafter merged 2 commits into
masterfrom
plan-based-pr-unique-key-local
Nov 24, 2026
Merged

devcrafter merged 2 commits into
masterfrom
plan-based-pr-unique-key-local

Conversation

@devcrafter

@devcrafter devcrafter commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

With plan-based parallel replicas (parallel_replicas_plan_based), a read of a UNIQUE KEY table is shipped to the replicas, and ReadFromMergeTree::serialize refuses it with distributed query plan is not supported on UNIQUE KEY tables (SUPPORT_IS_DISABLED), so the query fails. Query-based parallel replicas doesn't distribute such a read (isStorageEligibleForParallelReplicas).

mergeTreeReadCanBeShipped now refuses a read of a UNIQUE KEY table. It's used for every shipped read: the coordinated read, the broadcast side of a join, IN sets and Merge expansion. So the read stays on the initiator, and the rest of the query can still be distributed. #132872 was meant to do this, but was merged with only two tests pinned to query-based parallel replicas; this change restores the check and removes those pins and the UNIQUE KEY entries of the plan-based blacklist.

05871_pr_plan_based_unique_key_read covers a read of a UNIQUE KEY table alone, on either side of a join, and in an IN set, without the local plan. Every query fails without the change.

Closes: #128534
Related: #132872
Related: #133745

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

...

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.12.1.399-master (included in 26.12 and later)

@devcrafter devcrafter added the comp-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). label Nov 23, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0127144]

Summary: ✅


AI Review

Summary

Reviewed PR head 01271442f1216ad3a7829c41875925b75f4bf68b, the full diff, and all prior discussion. The PR keeps UNIQUE KEY reads local under plan-based parallel replicas by rejecting them in mergeTreeReadCanBeShipped, covering coordinated reads, join broadcast reads, IN subquery plans, and Merge expansion. It restores affected tests and adds focused regression coverage. No actionable blockers or majors found.

Missing context / blind spots
  • ⚠️ The current merge head's plan-based jobs have no per-test results yet, and local execution is unavailable in this review job. On implementation commit c5fb53437fa715b6c5ffb3ed65e67e1076667d84, the unchanged regression test passed five plan-based runs and 50 ASan runs; both tests whose setting pins were removed also passed the plan-based job. Completion of the current head's jobs would confirm the merged-base combination.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Nov 23, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 01271442f with master 0f38da1d6 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 14 s compile time in total, 7 of them have a recent master baseline.

Job report

@devcrafter
devcrafter requested a review from groeneai November 23, 2026 19:10

@groeneai groeneai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Checked at c5fb534.

  • ReadFromMergeTree::serialize throws SUPPORT_IS_DISABLED for any read whose metadata has a unique key, and mergeTreeReadCanBeShipped is the one predicate behind every shipped read: the coordinated read (mergeTreeReadCanBeCoordinated), the broadcast side of a join and the plan of an IN set (subtreeHasUnshippableRead), and Merge expansion (getExpandableReads, mayBeExpandedForParallelReplicas in topKThroughJoin.cpp). One check there covers all of them, next to the temporary-table, projection and Top-K rejections.
  • CI on this head: the 8 tests dropped from the blacklist, plus 04161 and 05493, are OK in both plan-based jobs (arm_binary, ParallelReplicas, plan-based, s3 storage, parallel and sequential). 05871_pr_plan_based_unique_key_read is OK in the plan-based job and in all five flaky checks (50 runs each).

One leftover: tests/queries/0_stateless/05836_unique_key_preserves_insert_order.sh (lines 51-54) has the same pin, SET parallel_replicas_plan_based = 0; under a comment linking #128534. It was added by 7eb6ee7 on 2026-11-20, after #132872, so this PR does not remove it. With this change it can go like the two others.

@devcrafter
devcrafter enabled auto-merge November 24, 2026 11:45
@devcrafter
devcrafter added this pull request to the merge queue Nov 24, 2026
Merged via the queue into master with commit 2c1919b Nov 24, 2026
195 checks passed
@devcrafter
devcrafter deleted the plan-based-pr-unique-key-local branch November 24, 2026 14:03
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 24, 2026
alexey-milovidov added a commit that referenced this pull request Nov 25, 2026
…y-serialization

Conflict resolution:

- `master` reverted the sparse serialization of `JSON` typed paths
  (#133486 reverting
  #111429), which removed
  `SerializationInfoNamed` and `SerializationInfoObject`. The `checkKindStacks`
  and `checkKindStackForType` overrides move back to `SerializationInfoTuple`,
  the ones of `SerializationInfoObject` are dropped together with the class,
  and `MutateTask` uses `canUseSparseSerialization` again instead of the
  removed `shouldCollectSerializationInfo`.
- `NativeWriter::getSerializationAndColumn`: keep the materialization of
  non-native `LowCardinality` columns for old peers on top of the reverted code.
- `tryGetSerializationHints` now takes the metadata snapshot
  (#133300): pass it through
  in the overrides this branch adds for the wrapper storages.
- `tests/parallel_replicas_plan_based_blacklist.txt`: `master` removed the whole
  `UNIQUE KEY` section, because plan-based parallel replicas now keep such reads
  local (#133744), so
  `05449_auto_low_cardinality_serialization_unique_key` is not listed anymore.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
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-not-for-changelog This PR should not be mentioned in the changelog 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.

Plan-based parallel replicas: a read from a UNIQUE KEY table is shipped and throws SUPPORT_IS_DISABLED

4 participants