Skip to content

Cherry pick #113742 to 26.3: Skip the custom-key parallel replicas read when the requested stage cannot absorb finalized data - #114632

Merged
robot-clickhouse-ci-2 merged 5 commits into
backport/26.3/113742from
cherrypick/26.3/113742
Aug 14, 2026
Merged

robot-clickhouse-ci-2 merged 5 commits into
backport/26.3/113742from
cherrypick/26.3/113742

Conversation

@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor

Original pull-request #113742

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

alexey-milovidov and others added 4 commits August 6, 2026 23:22
…annot absorb finalized data

The custom-key parallel replicas branch of the planner replaces the plan of a
table expression with a remote read at the fixed stage
`WithMergeableStateAfterAggregationAndLimit`, ignoring the stage the plan was
requested up to. A `Merge` table over a `Distributed` child plans all of its
children up to `WithMergeableState` through an interpreter, so a MergeTree
child's plan produced finalized (post-aggregation, post-LIMIT) data where the
parent `ReadFromMerge` expected partial aggregation states:
`CANNOT_CONVERT_TYPE` for `count`, and the exception `Chunk should have
AggregatedChunkInfo/ChunkInfoWithAllocatedBytes in GroupingAggregatedTransform`
when the finalized type structurally coincides with the state type. Allow the
custom-key read only when the requested stage is `Complete` or
`WithMergeableStateAfterAggregationAndLimit` itself.

Found by the targeted AST fuzzer on #110972 (an unrelated PR):
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110972&sha=ac0a584ce316ace31f4dbc16b38e1262a2344751&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%2C%20old_compatibility%29

Closes: #113741

Co-Authored-By: Claude Fable 5 <[email protected]>
…-stage

Skip the custom-key parallel replicas read when the requested stage cannot absorb finalized data
@robot-ch-test-poll4 robot-ch-test-poll4 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Aug 13, 2026
Resolve the conflict in `src/Planner/PlannerJoinTree.cpp`: on 26.3
`parallel_replicas_enabled_for_storage` is still a local lambda inside
`buildQueryPlanForTableExpression`, while master replaced it with the free function
`parallelReplicasEnabledForStorage`, so the whole block around the custom-key `if`
differs and git overlapped the two versions.

Took the 26.3 side for the entire block and re-applied only this pull request's own
hunk on top of it: the `to_stage_supports_custom_key` gate (`Complete` or
`WithMergeableStateAfterAggregationAndLimit`) on the 26.3
`if (query_context->canUseParallelReplicasCustomKey() && distributed_depth == 0)`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants