Skip to content

Write the serialized state of AggregateFunction in RawBLOB output - #127288

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix-rawblob-aggregate-function
Oct 24, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix-rawblob-aggregate-function

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

RawBLOB output wrote column.getDataAt(row_num) for every value. For ColumnAggregateFunction, getDataAt returns the 8 bytes of the pointer to the aggregate state rather than the state itself, so SELECT sumState(number) FROM numbers(3) FORMAT RawBLOB printed a memory address, and the actual state was lost regardless of its size.

Now an AggregateFunction column is written as its serialized state, the same bytes as CAST(state AS String) (no length prefix, consistent with how RawBLOB writes strings).

Related: #115250

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

The RawBLOB output format now writes the serialized state of AggregateFunction columns (the same as their conversion to String) instead of an in-memory pointer.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/127288]

Version info

  • Merged into: 26.11.1.709-master (included in 26.11 and later)
  • Backported to: 26.10.2.104, 26.9.26.15, 26.8.35.11, 26.3.61.9

`RawBLOBRowOutputFormat::writeField` used `getDataAt`, which for
`ColumnAggregateFunction` returns the bytes of the pointer to the state,
not the state. Serialize the state instead, the same way as its
conversion to `String`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1e8fe96]

Summary: ✅


AI Review

Summary

RawBLOB now writes serialized AggregateFunction states instead of heap pointers, matching conversion to String without adding delimiters or length prefixes. No actionable findings remain in the current diff.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). labels Oct 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 1e8fe96ab with master eddf9eec0 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 4ad5968c3; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

4 object files changed (+24.12 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/RawBLOBRowOutputFormat.cpp.o 81.77 KiB 105.88 KiB +24.11 KiB (+29.48%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

7 translation units recompiled, 7 s compile time in total, 7 of them have a recent master baseline.

Job report

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=127288&sha=96f4b075c65837d7408270a2a58f6bbd3fdc6abf&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29 (std::terminate in ReplicatedMergeTreeQueue::pullLogsToQueue, STID: 4362-23be) and provide a fix in a separate PR. If the fix is already in progress, link it here. It is unrelated to this PR, which only changes RawBLOB output. The generate_random_json performance change is also unrelated (this PR does not touch generateRandom or JSON); master has been merged into the branch.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix is already merged: #127123 (2026-10-22 21:16 UTC).

This run's clickhouse-server.err.log has t_merge_missing_znode_r1 and _r2 (test 05230) failing in ReplicatedMergeTreeQueue::insertUnlocked with Unexpected part name: for format version: 1. (BAD_DATA_PART_NAME) at 02:38:40, after which pullLogsToQueue calls std::terminate on purpose (ReplicatedMergeTreeQueue.cpp:984). When stress fault injection breaks the setup of 05229/05230, the captured part name is empty, but the test still wrote a replication log entry with that name into ZooKeeper. #127123 makes both tests check their setup before any ZooKeeper write.

The run started at 2026-10-22 00:19 UTC, about 21 hours before the merge, so its tree did not have the fix. Since the merge, CIDB has no STID: 4362-* row and no pullLogsToQueue terminate in about 2,960 Stress test jobs. Not caused by this PR.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 24, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 24, 2026
@alexey-milovidov alexey-milovidov added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Oct 24, 2026
Merged via the queue into master with commit 29f0e51 Oct 24, 2026
179 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-rawblob-aggregate-function branch October 24, 2026 03:08
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 24, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 24, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 24, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 24, 2026
Backport #127288 to 26.10: Write the serialized state of `AggregateFunction` in `RawBLOB` output
clickhouse-gh Bot added a commit that referenced this pull request Oct 24, 2026
Backport #127288 to 26.8: Write the serialized state of `AggregateFunction` in `RawBLOB` output
clickhouse-gh Bot added a commit that referenced this pull request Oct 24, 2026
Backport #127288 to 26.9: Write the serialized state of `AggregateFunction` in `RawBLOB` output
alexey-milovidov added a commit that referenced this pull request Oct 24, 2026
Backport #127288 to 26.3: Write the serialized state of `AggregateFunction` in `RawBLOB` output
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants