Skip to content

Check the range of bucket numbers in BlockInfo - #131302

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix-block-info-bucket-num-range
Nov 13, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix-block-info-bucket-num-range

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

BlockInfo::bucket_num and BlockInfo::out_of_order_buckets are read from the native protocol and from temporary files of external aggregation, and are used as indices of the 256 buckets of two-level aggregation. The number of out_of_order_buckets is already bounded; now their values and bucket_num must be in range (from -1 for bucket_num, and from 0 for out_of_order_buckets, to 255), otherwise INCORRECT_DATA is thrown.

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):

Validate the bucket numbers of two-level aggregation in blocks received over the native protocol. Original fix by @motsc and @CheSema.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.2248-master (included in 26.11 and later)

`BlockInfo::bucket_num` and `BlockInfo::out_of_order_buckets` are read from the native protocol and from temporary files of external aggregation, and are used as indices of the 256 buckets of two-level aggregation. The number of `out_of_order_buckets` is already bounded; now their values and `bucket_num` must be in range (from -1 for `bucket_num`, and from 0 for `out_of_order_buckets`, to 255), otherwise `INCORRECT_DATA` is thrown.

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

clickhouse-gh Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b9cceca]

Summary: ✅


AI Review

Summary

Reviewed commit b9cceca9d5518496248d34ef3c3f199f0b672629. The change validates BlockInfo::bucket_num against [-1, 255] and each out_of_order_buckets entry against [0, 255], with focused regression coverage. No actionable findings.

Missing context / blind spots
  • ⚠️ Unit tests and unit bugfix validation are still pending in the CI report. No local build is available; completion of these jobs would confirm execution of the added regression test.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Nov 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing b9cceca9d with master 07cb9a7b6 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 92f8fd758; 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.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.61, programs/clickhouse-keeper ×0.71 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 5.8 s 12.9 s +9.3 s (+262%)
programs/clickhouse _ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… 3.4 s 7.2 s +5.1 s (+248%)
Compile time of recompiled translation units

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

Job report

@clickhouse-gh clickhouse-gh Bot added the comp-aggregation GROUP BY / aggregation framework (hash tables, spilling, external aggregation). label Nov 13, 2026
@alexey-milovidov alexey-milovidov self-assigned this Nov 13, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 13, 2026
Merged via the queue into master with commit dcf6e7b Nov 13, 2026
208 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-block-info-bucket-num-range branch November 13, 2026 21:19
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 13, 2026
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-ClickHouse__ClickHouse that referenced this pull request Nov 13, 2026
…ed as paths, two readings of one input

Blind reviews of the pull requests that introduced nine bugs fixed later (ported in ClickHouse#131294-ClickHouse#131302) showed these gaps:
- Data the server wrote itself and reads back (parts, patch parts, packed-file indexes, `ssd_cache` files) was
  treated as trusted, so out-of-bounds reads on it were dismissed or rated as Nits (ClickHouse#126553, ClickHouse#116007, ClickHouse#86095).
- No prompt for overflow of sizes computed from user-controlled counts (`ColumnString::replicate`, ClickHouse#61075).
- No prompt for names read from data that become paths (packed archive index, ClickHouse#93414).
- A security check that reads its input differently from the consumer (first vs last repeated key, Boolean
  spellings), which the real review of ClickHouse#106855 missed.
Also ask for a separate pass over parsers and security decisions in large pull requests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-aggregation GROUP BY / aggregation framework (hash tables, spilling, external aggregation). pr-bugfix Pull request with bugfix, not backported by default 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.

2 participants