Skip to content

Pin 04161 and 05493 to query-based parallel replicas - #132872

Merged
devcrafter merged 1 commit into
ClickHouse:masterfrom
groeneai:pr-plan-based-unique-key-local-read
Nov 19, 2026
Merged

devcrafter merged 1 commit into
ClickHouse:masterfrom
groeneai:pr-plan-based-unique-key-local-read

Conversation

@groeneai

@groeneai groeneai commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #128534
Related: #128413

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Description

04161_unique_key_insert_duplicate and 05493_unique_key_disk_without_append fail in Stateless tests (arm_binary, ParallelReplicas, plan-based, s3 storage, parallel) with distributed query plan is not supported on UNIQUE KEY tables (SUPPORT_IS_DISABLED): plan-based parallel replicas ships the read of a UNIQUE KEY table (#128534). Both read such a table only through count(), so they fail only when the runner draws optimize_trivial_count_query = 0 (5% of runs; 5/140 and 4/132 in this job over 30 days) and pass otherwise.

The plan-based blacklist is checked strictly (the job runs without --autopr), so listing them would report NOT_FAILED on most runs, as 04161 did 9 times on #128413. Both tests now pin query-based parallel replicas, as 91d6019 did for 05175. #128534 stays open for plan-based support, and the 8 UNIQUE KEY tests in the blacklist keep tracking it.

Validation: in a local plan-based job setup on master code (05493 with local stand-ins for its S3 disks), with optimize_trivial_count_query = 0 both unchanged tests fail 3/3 and both pinned tests pass 3/3; with the unchanged 05493 listed in the blacklist, default runs report NOT_FAILED 2/2. The pinned tests pass 50/50 with random settings.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.2874-master (included in 26.11 and later)

@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding;
bounded: 1 full pass + 1 fix round + 1 delta recheck).

# Sev Finding Verdict Evidence / action
1 ⚠️ 05832_pr_plan_based_unique_key_read checks results only: it cannot tell this guard from one that keeps the whole query local, the join sides are not pinned, and Merge expansion is not covered DISAGREE The guard is one per-read check in mergeTreeReadCanBeShipped, so it cannot refuse a read of another table. A refused broadcast-side read leaves the coordinated read distributed through liftSplitAboveJoin, the path 05497_pr_plan_based_temporary_table_read_stays_local already pins with EXPLAIN. The runner draws query_plan_join_swap_table only from auto/false, and with both the second query keeps the UNIQUE KEY table on the broadcast side; the first query is the coordinated read. Merge expansion calls the same predicate for each child (ReadFromMerge::computeExpandableReads), wiring pinned by 04908_pr_plan_based_merge_table_shapes. Each of the 4 queries fails on the base binary with SUPPORT_IS_DISABLED.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-review-slot-8:20261119-040001

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. SELECT count() FROM t_uk (UNIQUE KEY table) with enable_parallel_replicas = 1, parallel_replicas_plan_based = 1, optimize_trivial_count_query = 0 throws SUPPORT_IS_DISABLED on every run; so does 04161_unique_key_insert_duplicate with --client-option optimize_trivial_count_query=0.
b Root cause explained? mergeTreeReadCanBeShipped had no UNIQUE KEY rule, unlike isStorageEligibleForParallelReplicas and getReasonReadCannotBeDistributed. The read was put into a shipped fragment and ReadFromMergeTree::serialize refused it. Trivial count hides the read in 04161 95% of the time.
c Fix matches root cause? Yes. The predicate that decides shipping refuses the read; the serialize check stays as a backstop.
d Test intent preserved / new tests added? New 05832_pr_plan_based_unique_key_read (read, both join sides, IN set). The 8 tests the plan-based blacklist masked run again and pass; 04161 is unchanged.
e Both directions demonstrated? Base: the repro, 04161, the new test and the 8 tests fail with this error. Fix: they pass at parallel_replicas_local_plan 0 and 1 (5 runs each), and 50/50 with random settings for the new test and 04161.
f Fix is general across code paths? Yes. All plan-based entry points use this predicate: coordinated reads, join broadcast side, IN / nested / GLOBAL IN sets, views (each probed: base fails, fix passes) and Merge expansion (getExpandableReads(mergeTreeReadCanBeShipped)). Query-based and make_distributed_plan already refuse.
g Fix generalizes across inputs (params/datatypes/wrappers)? Type wrappers N/A (table property). Checked at local_plan 0/1, with random settings, in the default profile, and remote() with serialize_query_plan = 1.
h Backward compatible? (maintainer-approved exception only) Yes. No setting or format change; a query that threw now reads locally, like query-based parallel replicas.
i Invariants and contracts preserved? Yes. The predicate only returns false earlier; a refused read is not distributed, the same path as the existing rules.

Session id: cron:clickhouse-impl-slot-41:20261119-031000

@clickhouse-gh

clickhouse-gh Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4375cce]

Summary: ✅


AI Review

Summary

Reviewed head 4375cce63830ef51348fb5250e7a3f1dbd9c7e6e and all prior discussion. The PR sets parallel_replicas_plan_based = 0 in 04161_unique_key_insert_duplicate and 05493_unique_key_disk_without_append, avoiding the tracked unsupported UNIQUE KEY read while retaining their duplicate-key and disk-capability assertions. No actionable blockers or majors found. The prior resolved finding concerns a fixture removed from the final diff.

Missing context / blind spots
  • ⚠️ The head plan-based CI report contains no per-test results yet, and this checkout has no ClickHouse binary for an independent rerun. The author reports both tests failing before and passing after the change with optimize_trivial_count_query = 0, plus 50 randomized passes each. A head CI run exercising that setting would independently confirm this evidence.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog can be tested Allows running workflows for external contributors comp-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). labels Nov 19, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing c4c38d9b5 with master 92fdcb78e (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

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

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - c4c38d9

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, ParallelReplicas, plan-based, s3 storage, parallel) / 05829_autopr_skip_index_on_read_in_subquery not from this PR (it changes the plan-based read of a UNIQUE KEY table and adds 05832_pr_plan_based_unique_key_read): the same deterministic red of this test under the plan-based parallel replicas job is on 12 master commits since 2026-11-19 00:41Z (master report) and on 51 other PRs #132867 (mine, open)
PR praktika rollup of the row above #132867 (mine, open)

Mergeable Check is red only because of the row above; CH Inc sync is green. CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261119-080025

@devcrafter
devcrafter added this pull request to the merge queue Nov 19, 2026
@devcrafter
devcrafter removed this pull request from the merge queue due to a manual request Nov 19, 2026
@devcrafter

Copy link
Copy Markdown
Member

@groeneai just add previous failed test 05493_unique_key_disk_without_append in blacklist for plan-based parallel replicas. Query-based parallel replicas works in this case. For plan-based it should implemented separately, not by disalbling, so related issue should stay open

@devcrafter
devcrafter self-requested a review November 19, 2026 11:38
With `parallel_replicas_plan_based = 1`, a read of a `UNIQUE KEY` table is
shipped and `ReadFromMergeTree::serialize` throws `SUPPORT_IS_DISABLED`
(ClickHouse#128534). `04161_unique_key_insert_duplicate` and
`05493_unique_key_disk_without_append` read such a table only through
`count()`, so in the plan-based job they fail only when the runner draws
`optimize_trivial_count_query = 0` (5% of runs) and pass otherwise.

The plan-based blacklist is checked strictly (the job does not run with
`--autopr`), so listing them would report `NOT_FAILED` on most runs, as it
did for 04161 on ClickHouse#128413. Pin them to query-based parallel replicas
instead, the way 91d6019 did for 05175. ClickHouse#128534 stays open for
plan-based support of `UNIQUE KEY` reads.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=6ade2c8d6b94ea04a0c7b0259825529aceac0fd8&name_0=MasterCI&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20plan-based%2C%20s3%20storage%2C%20parallel%29

Related: ClickHouse#128534

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai
groeneai force-pushed the pr-plan-based-unique-key-local-read branch from c4c38d9 to 4375cce Compare November 19, 2026 12:27
@groeneai groeneai changed the title Plan-based parallel replicas: keep reads of UNIQUE KEY tables local Pin 04161 and 05493 to query-based parallel replicas Nov 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Done in 4375cce: I dropped the mergeTreeReadCanBeShipped change and 05832, so the plan-based blacklist keeps its UNIQUE KEY block, and #128534 is now only Related: and stays open.

I did not list 05493 in the blacklist, because it would report NOT_FAILED there. It fails only when the runner draws optimize_trivial_count_query = 0 (4 of 132 runs in this job over 30 days), and the plan-based list is checked strictly without --autopr. I measured this locally, and 04161 did the same 9 times on #128413. Instead, 05493 and 04161 now set parallel_replicas_plan_based = 0 with a link to #128534, as 91d6019 did for 05175. If you prefer the blacklist entry anyway, I'll switch to it.

@clickhouse-gh clickhouse-gh Bot added pr-ci and removed pr-not-for-changelog This PR should not be mentioned in the changelog labels Nov 19, 2026
@devcrafter
devcrafter enabled auto-merge November 19, 2026 13:01
@clickhouse-gh clickhouse-gh Bot added comp-testing Test content only (no production code). and removed comp-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). labels Nov 19, 2026
@devcrafter
devcrafter added this pull request to the merge queue Nov 19, 2026
Merged via the queue into ClickHouse:master with commit c4283ab Nov 19, 2026
202 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 19, 2026
alexbakharew added a commit to aschoube/ClickHouse that referenced this pull request Nov 20, 2026
`05836_unique_key_preserves_insert_order` fails in `Stateless tests
(arm_binary, ParallelReplicas, plan-based, s3 storage, parallel)`. Plan-based
parallel replicas cannot read a `UNIQUE KEY` table yet (`SUPPORT_IS_DISABLED`),
see ClickHouse#128534. Set
`parallel_replicas_plan_based = 0` for the final `SELECT` of the test, as
ClickHouse#132872 did for two other tests.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=128833&sha=7016cca5a1e22feb060ace1d9ce40eba62adfe09&name_0=PR
ClickHouse#128833
@clickhouse-gh clickhouse-gh Bot added comp-unique-key Unique key in MergeTree: uniqueness enforced on insert through a key index (SST / dense index), d... and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-unique-key Unique key in MergeTree: uniqueness enforced on insert through a key index (SST / dense index), d... pr-ci 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.

3 participants