Repository navigation
Ship _shard_num with plan-based parallel replicas fragments; test follower analysis without a local plan - #127014
Conversation
…l plan With `parallel_replicas_index_analysis_only_on_coordinator`, a follower skipped its own index analysis whenever `parallel_replicas_local_plan` was set, relying on the analysis of the initiator's local plan. Inside a `Distributed` subquery and with `parallel_replicas_prefer_local_replica = 0` there is no local plan, so nobody analyzed and every replica read whole parts: 1280000 rows instead of 384 for a primary key range of 3 granules through `Distributed`. The check now uses `ClusterProxy::canUseLocalPlanForParallelReplicas`, which covers both. Review: #126954 (comment) Related: #126954 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [9d26358] Summary: ✅
AI ReviewSummaryThe PR forwards query scalars, including Final Verdict✅ Approve for head |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 17 s compile time in total, 7 of them have a recent master baseline. |
`ReadFromParallelReplicasStep` sent `Scalars{}` to the followers, so inside a `Distributed` sub-query
they did not see `_shard_num`, assumed the initiator runs a local plan, and skipped their own index
analysis: every follower read whole parts. Send the query context's scalars, as the query-based path
does. The test now runs both cases with `parallel_replicas_plan_based` = 0 and 1.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
_shard_num with plan-based parallel replicas fragments; test follower analysis without a local plan
groeneai
left a comment
There was a problem hiding this comment.
I ran the CI amd_debug binaries of this head (9d263588) and of its master base (8e3eb7ad) on a local 1-shard x 3-replica cluster. 05428 gives plan_based_distributed 0 on the base and matches the reference on the head; the other three modes pass on both.
One non-blocking suggestion: getScalars() also ships every scalar-subquery result, which a plan fragment does not need, since the value is already folded into the plan (on the base, followers evaluate has((SELECT groupArray(number * 10) FROM numbers(100)), k) correctly with Scalars{}). For SELECT sum(k) FROM t WHERE k < length((SELECT groupArray(number) FROM numbers(1000000))) with parallel_replicas_plan_based = 1, parallel_replicas_prefer_local_replica = 0, the initiator's NetworkSendBytes goes from 15 KB on the base to 10.1 MB on this head. Shipping only _shard_num avoids that:
Scalars scalars;
if (context->hasQueryContext() && context->getQueryContext()->hasScalar("_shard_num"))
scalars.emplace("_shard_num", context->getQueryContext()->getScalar("_shard_num"));I built that on master ebff85ed: 05428 passes, that query sends 19 KB, and the array scalar subquery and shardNum()/shardCount() through Distributed return the same results as on the base.
LGTM otherwise.
|
@groeneai thanks for the suggestion in #127014 (review): #133844 sends only |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Plan-based parallel replicas (
parallel_replicas_plan_based = 1) used through aDistributedtable now apply primary key and skip index analysis on the followers instead of reading whole parts.Related: #126792
Related: #126954
Related: #126955
With
parallel_replicas_index_analysis_only_on_coordinator(the default), a follower skips its own index analysis and relies on the analysis of the initiator's local plan. Without a local plan - parallel replicas inside aDistributedsub-query, orparallel_replicas_prefer_local_replica = 0- nobody analyzed, and every replica read whole parts. #126792 fixed this in master by checkingClusterProxy::canUseLocalPlanForParallelReplicason the follower; this PR adds a test for it.The test also found a case that fix misses. A follower recognizes the
Distributedcase by the_shard_numscalar the initiator ships, but withparallel_replicas_plan_based = 1the plan fragment was sent withScalars{}(ReadFromParallelReplicasStep::createPipeForSingeReplica). The followers then assumed a local plan, skipped the analysis, and read whole parts again. The fragment now carries the query context's scalars, as the query-based path does.Workflow [PR]
Sync PR [sync-upstream/pr/127014]
Version info
26.11.1.1285-master(included in26.11and later)