Skip to content

Backport #131789 to 26.9: Check the aggregates of deserialized query plan steps against their input - #133175

Merged
clickhouse-gh[bot] merged 7 commits into
26.9from
backport/26.9/131789
Nov 22, 2026
Merged

clickhouse-gh[bot] merged 7 commits into
26.9from
backport/26.9/131789

Conversation

@robot-ch-test-poll

@robot-ch-test-poll robot-ch-test-poll commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #131789

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.9.37.4

@robot-ch-test-poll robot-ch-test-poll added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-critical-bugfix labels Nov 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [97e5ef3]

Summary: ✅

alexey-milovidov and others added 6 commits November 20, 2026 11:25
The backport dropped `#include <Core/Block_fwd.h>` from `AggregateDescription.h`
and `#include <Core/Block.h>` from `AggregateDescription.cpp`, which the
original change has on master; on 26.9 nothing else brings `Block` into scope,
so every build failed with "unknown type name 'Block'".

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=133175&sha=cc5a655eb8cd1608444d1bd0643deef567b0863e&name_0=BackportPR&name_1=Build%20%28amd_release%29
PR: #133175

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rgument_types` to 19 in the backport

The test pinned version 21, the current one on master, but 26.9 serializes plans with
`DBMS_QUERY_PLAN_SERIALIZATION_VERSION` = 19, so the server refused every forged plan with
`NOT_IMPLEMENTED`. The test sends no step settings, so the byte layout of the forged steps is the
same at version 19 (the sibling test `05790_filling_step_repeated_interpolate_output` pins 19 too).

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=133175&sha=c411f93684ec4f1c3f89d40694385ac010c1d411&name_0=BackportPR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29
PR: #133175

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the binary format of 26.9

The test wrote the settings of a forged step as on master: name, flags and the value as a string,
terminated by an empty name. 26.9 reads them with `BaseSettings::readBinary`: the number of
settings, then name, flags and the binary value of each. The first forged plan with a step setting
(`distributed_aggregation_memory_efficient` of `MergingAggregated`) was therefore misread, the
server waited for more bytes, and the test timed out reading the response. Plans without settings
were not affected, as the terminating empty name and a zero count are the same byte.

Checked against the `arm_release` binary built by CI for b198d44,
started with `process_query_plan_packet`: the previous version of the test times out on
`grouping set key is repeated after the states`, this one matches the reference.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=133175&sha=b198d44b4bbfebcb764a47f5de53271f86a3097d&name_0=BackportPR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29
PR: #133175

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=133175&sha=b198d44b4bbfebcb764a47f5de53271f86a3097d&name_0=BackportPR&name_1=Stress%20test%20%28amd_tsan%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

ThreadSanitizer: heap-use-after-free (STID: 0988-3434) in memcpySmallAllowReadWriteOverflow15Impl under readEscapedStringInto ← TabSeparatedFormatReader::readField ← StorageObjectStorageSource::generate, reading a 24-byte heap block allocated in the constructor of ReadBufferFromAzureBlobStorage and freed in Poco::Message::~Message from createReadBuffer. It is in the reading of a TSV file from Azure blob storage on the 26.9 branch and is unrelated to this backport, which only touches the aggregation steps of a deserialized query plan.

The other failure, 05791_aggregating_step_argument_types, was caused by the test of this backport: it wrote the step settings in the string format of master, while 26.9 reads them in the binary format, so the server waited for more bytes. Fixed in 4a03d7e and checked against the arm_release binary built by CI for the previous head.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix is already merged: #127593 (pad the buffer that ReadBufferFromAzureBlobStorage owns with PADDING_FOR_SIMD), backported to 26.9 as #133296 (merged 2026-11-20 21:37 UTC) and to 26.10 as #133226. The linked run started at 13:43 UTC that day, before #133296 merged; the current head 97e5ef3 contains it.

The report is the 15-byte SIMD over-read of an unpadded buffer, not a real use-after-free: the read at 0x720800754318 is one byte past the end of the 24-byte std::vector<char> tmp_buffer at 0x720800754300 (ReadBufferFromAzureBlobStorage.cpp:176), and TSan reports the earlier Poco::Message free of that allocator slot. The 24-byte TSV of 05534_azure_partition_id_with_url_shaped_key, which reached 26.9 with #133148, triggers it.

Since #133296 merged, CIDB has no report of this STID (or its ASan form 0988-35bc) on any branch or PR. On 26.9 that covers 5 commits of Stress test (amd_tsan), 4 of Stress test (arm_tsan) and 4 of Stateless tests (amd_asan_ubsan, distributed plan, parallel). No new PR is needed.

@clickhouse-gh
clickhouse-gh Bot merged commit a1c41a1 into 26.9 Nov 22, 2026
45 checks passed
@clickhouse-gh
clickhouse-gh Bot deleted the backport/26.9/131789 branch November 22, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants