Skip to content

Do not wrap around when rounding row and byte settings to marks - #126536

Merged
alexey-milovidov merged 3 commits into
masterfrom
fix-round-rows-to-marks-overflow
Oct 21, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
fix-round-rows-to-marks-overflow

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

MergeTreeDataSelectExecutor::roundRowsOrBytesToMarks rounded up with (setting + granularity - 1) / granularity, which wrapped around to 0 for a setting close to the maximum:

  • the maximum values of merge_tree_max_rows_to_use_cache and merge_tree_max_bytes_to_use_cache, which mean "always use the cache", disabled the uncompressed cache for every query;
  • the maximum values of merge_tree_min_rows_for_seek and merge_tree_min_bytes_for_seek became 0.

It now rounds up without the addition.

Found while enabling the UBSan check for unsigned integer overflows.

Related: #120906

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

Fix the uncompressed cache being disabled when merge_tree_max_rows_to_use_cache and merge_tree_max_bytes_to_use_cache are set to their maximum value, and the same wraparound for merge_tree_min_rows_for_seek and merge_tree_min_bytes_for_seek.

🤖 Generated with Claude Code


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

Version info

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

`MergeTreeDataSelectExecutor::roundRowsOrBytesToMarks` rounded up with
`(setting + granularity - 1) / granularity`, which wrapped around to 0 for a
setting close to the maximum. The maximum values of `merge_tree_max_rows_to_use_cache`
and `merge_tree_max_bytes_to_use_cache`, which mean "always use the cache",
disabled the uncompressed cache for every query, and the maximum
`merge_tree_min_rows_for_seek` and `merge_tree_min_bytes_for_seek` became 0.

Found while enabling the UBSan check for unsigned integer overflows in
#120906.

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

clickhouse-gh Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3593ab2]

Summary: ✅


AI Review

Summary

PR #126536 replaces overflowing ceiling division in MergeTreeDataSelectExecutor::roundRowsOrBytesToMarks, preserving cache and seek thresholds near the UInt64 maximum. The regression test passes in Fast test for the reviewed head. Both prior findings are addressed, and no actionable findings remain.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. labels Oct 17, 2026
alexey-milovidov and others added 2 commits October 20, 2026 06:07
@clickhouse-gh

clickhouse-gh Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 3593ab242 with master c8a410bb9 (stripped binary size, per-symbol sizes and ThinLTO time; 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.

Compile time of recompiled translation units

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

Job report

@alexey-milovidov alexey-milovidov self-assigned this Oct 21, 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 Oct 21, 2026
Merged via the queue into master with commit 214443b Oct 21, 2026
180 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-round-rows-to-marks-overflow branch October 21, 2026 19:13
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. 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