Skip to content

Cherry pick #131736 to 26.10: Reject serialized query plan steps without their inputs - #132268

Merged
robot-ch-test-poll3 merged 8 commits into
backport/26.10/131736from
cherrypick/26.10/131736
Nov 17, 2026
Merged

robot-ch-test-poll3 merged 8 commits into
backport/26.10/131736from
cherrypick/26.10/131736

Conversation

@robot-clickhouse

Copy link
Copy Markdown
Member

Original pull-request #131736

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.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

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 7 commits November 15, 2026 04:21
The number of children of a step in a serialized query plan comes from the stream, but the step deserializers read their input headers (`ctx.input_headers.front()` and similar) without checking it, so a plan with a step lacking its children made the server read out of bounds. Make `QueryPlanStepDeserialization::input_headers` a checked view that throws `INCORRECT_DATA` for a missing input, which covers all steps at once, and reject a `UnionStep` without inputs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`DeserializedInputHeaders` stores a reference, so the temporary `SharedHeaders{header}`
used to initialize the deserialization context in the gtest was destroyed right after the
initialization. This made `LimitByStepSerialization` fail in unit tests, with
`stack-use-after-scope` under ASan. Use a named vector, and delete the rvalue constructor
of `DeserializedInputHeaders` so other callers cannot get the same dangling reference.

Address review feedback.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A step may take fewer inputs than its node has children, e.g. `Extremes` with two
children stores one input header, while optimizations iterate over the children and
read the input header of each of them out of bounds. Check that the number of input
headers of each deserialized step equals the number of its children.

Also replace the `chassert` in `BlocksMarshallingStep::deserialize` with an
`INCORRECT_DATA` exception: a childless step aborted debug and sanitizer servers.
Extend the test with both cases.

Address review feedback.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A sink such as `GatherSend` has no output header, so calling `getOutputHeader`
on it while collecting the input headers of its parent raised a `LOGICAL_ERROR`
exception. Throw `INCORRECT_DATA` instead, and extend the test with a sink
beneath another step.

Also mark the accessors of `DeserializedInputHeaders` `[[nodiscard]]` as
required by `modernize-use-nodiscard`.

Address review: #131736 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolved the test conflict by keeping the remote's `buildNode` helper and the
new cases, and adding the `Extremes` over `GatherSend` case on top of it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g-inputs

Reject serialized query plan steps without their inputs
@robot-clickhouse robot-clickhouse 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-critical-bugfix labels Nov 17, 2026
Resolve the conflict in `src/Processors/QueryPlan/Serialization.cpp`: 26.10 has no
`MAX_QUERY_PLAN_STEP_CHILDREN` limit (nor `TOO_LARGE_ARRAY_SIZE` there), so keep only the
new `DeserializedInputHeaders::at` from the original PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robot-ch-test-poll3
robot-ch-test-poll3 merged commit 11ca136 into backport/26.10/131736 Nov 17, 2026
2 checks passed
@robot-ch-test-poll3
robot-ch-test-poll3 deleted the cherrypick/26.10/131736 branch November 17, 2026 08:33
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-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants