Repository navigation
Size parallel replicas mark segments by the active replica count capped by max_parallel_replicas - #133260
Conversation
The reading coordinator is sized by the active replicas of `cluster_for_parallel_replicas`, at most `max_parallel_replicas` (ClickHouse#107805), but `ReadFromMergeTree` still passed the registered replica count of the cluster as `total_nodes_count`, which `chooseSegmentSize` uses to pick the automatic `mark_segment_size`. With stale registrations of a `Replicated` database, or a cluster larger than `max_parallel_replicas`, the heuristic divided by replicas that take no part in the query. Extract the liveness half of `prepareConnectionPoolsForParallelReplicas` into `getParallelReplicasLiveness` and add `getReplicasCountForParallelReplicas`, which counts replicas by the coordinator's rules. `ReadFromMergeTree` computes it once per step (the liveness may be a Keeper read, and a read in order builds an extension per split) and uses it for every `ParallelReadingExtension`. The `chooseSegmentSize` trace line now logs the count, and the existing integration test checks it with one of three replicas stopped and with `max_parallel_replicas = 2`. Related: ClickHouse#107805 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the liveness helper and cache docs to one line; drop a fallback comment the header already states. 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; 3 findings), plus my own review (3 nits, not listed).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261120-152900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20261120-145000 |
|
Workflow [PR], commit [dc2a328] Summary: ✅
AI ReviewSummaryReviewed PR #133260 at Missing context / blind spots
Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units164 translation units recompiled, 1477 s compile time in total, 164 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.94 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
361db3a
Related: #107805
Related: #109377
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The automatic choice of
parallel_replicas_mark_segment_sizenow counts only the replicas that take part in the query: the active replicas ofcluster_for_parallel_replicas, at mostmax_parallel_replicas, the same count the reading coordinator uses. Before, stale replicas of aReplicateddatabase and replicas beyondmax_parallel_replicaswere counted too, which could choose a smaller segment.Description
Replaces #109377 with the minimal version agreed there.
Since #107805 the parallel replicas reading coordinator is sized by the active replicas of
cluster_for_parallel_replicas, at mostmax_parallel_replicas.ReadFromMergeTreestill passed the registered replica count astotal_nodes_count, andchooseSegmentSizedividessum_marksby its square to pick the automatic segment size. So stale registrations of aReplicateddatabase, or a cluster larger thanmax_parallel_replicas, counted replicas that take no part in the query.The liveness part of
prepareConnectionPoolsForParallelReplicas(liveness lookup, size check, local replica forced active) moves intogetParallelReplicasLiveness, and the newgetReplicasCountForParallelReplicascounts with it by the coordinator's rules.ReadFromMergeTreecomputes it once per step (the liveness can be a Keeper read) and uses it for everyParallelReadingExtension. A follower counts from its own liveness; the coordinator keeps the segment size of the announcement that initializes it, so a different follower value changes nothing.Example, 3 replicas,
max_parallel_replicas = 2, a 6250-mark read with one thread and small read tasks: master divides by 3 and picks segment 128, this PR divides by 2 and picks 1024; the coordinator has 2 replicas in both. With the AutoPR CI config (11 replicas,max_parallel_replicas = 3) the count goes from 11 to 3.Validation: the existing
test_parallel_replicas_skip_inactive_replicasnow checksnumber_of_replicas(added to thechooseSegmentSizetrace line) with one of 3 replicas stopped and withmax_parallel_replicas = 2. It fails on master, each case fails when its half of the rule (liveness, cap) is removed, and it passed 5/5 with the fix. 8 parallel replicas stateless tests x10 with random settings: 80/80.Workflow [PR]
Sync PR [sync-upstream/pr/133260]
Version info
26.12.1.102-master(included in26.12and later)