Skip to content

Add merge_selector_min_age_to_disable_right_tail_heuristic to disable right tail heuristic for partitions no longer being written to - #122638

Merged
alexey-milovidov merged 4 commits into
masterfrom
continue-pr-105454-right-tail-min-age
Oct 1, 2026
Merged

alexey-milovidov merged 4 commits into
masterfrom
continue-pr-105454-right-tail-min-age

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Supersedes #105454 by @tanner-bruce (Shopify), which could not be updated because maintainer edits are disabled on the fork. The original commits are kept to preserve authorship. On top of them, this PR merges current master: the setting's history moves into its DECLARE in MergeTreeSettings.cpp (26.10), and the gtests now use master's helpers.

Adds an opt-in MergeTree setting, merge_selector_min_age_to_disable_right_tail_heuristic, for the Simple and StochasticSimple merge selectors. When it is non-zero, the selector skips the right-tail small-part removal heuristic for candidate ranges where every part is at least that many seconds old. The default is 0, so merge behavior does not change unless the setting is enabled. This helps compact old immutable partitions, where the right-tail heuristic can leave small parts stranded at the end of a partition.

This is different from min_partition_age_to_force_merge_seconds, which is already on master: that setting forces merges in idle partitions but explicitly does not disable the right-tail heuristic.

Related: #105454
Closes: #70912
Related: #79697

Changelog category (leave one):

  • Improvement

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

Added the merge_selector_min_age_to_disable_right_tail_heuristic MergeTree setting. It lets the Simple and StochasticSimple merge selectors include small parts at the right end of a range in merge candidates once every part in the range is old enough.

Documentation entry for user-facing changes

  • Documentation is generated from the MergeTree setting description in MergeTreeSettings.cpp.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.1189-master (included in 26.10 and later)

tanner-bruce and others added 4 commits May 26, 2026 11:55
…right-tail-min-age

Resolve conflicts with master's reworked `MergeTreeSettings.cpp` layout:
the settings history for `merge_selector_min_age_to_disable_right_tail_heuristic`
moves from `SettingsChangesHistory.cpp` into the `DECLARE` itself (26.10), and
`gtest_simple_merge_selector.cpp` takes master's helpers plus a per-part-age
`makePartsRange` overload used by this PR's tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ht-tail gtest helper

Master enabled that heuristic by default, and it dereferences
`partitions_stats`, which `selectRightTailRange` does not provide. Turn it
off next to `enable_heuristic_to_align_parts` so the tests isolate the
right-tail heuristic.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6f33058]

Summary: ✅


AI Review

Summary

This PR adds an opt-in MergeTree setting, merge_selector_min_age_to_disable_right_tail_heuristic, and threads it through the Simple / StochasticSimple merge-selector path so old-enough ranges can keep their small right-tail parts in the candidate instead of trimming them away. I did not find a correctness, compatibility, or coverage issue in the changed code path.

Final Verdict

Status: ✅ Approve

LLVM Coverage Report

Measured on commit 6f33058.

Metric Baseline Current Δ
Lines 88.20% 88.20% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 79.60% 79.60% +0.00%

Changed lines: Changed C/C++ lines covered: 31/31 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. labels Sep 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 6f3305890 with master c9cb86303 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 662762793; 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

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

Job report

@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.

Good.

@alexey-milovidov alexey-milovidov self-assigned this Oct 1, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 1, 2026
Merged via the queue into master with commit 4bafd87 Oct 1, 2026
150 checks passed
@alexey-milovidov
alexey-milovidov deleted the continue-pr-105454-right-tail-min-age branch October 1, 2026 16:43
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 1, 2026
@clickhouse-gh clickhouse-gh Bot added comp-merges Merges of data parts: choosing what to merge (merge selectors, merge predicates, part collectors)... and removed comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-merges Merges of data parts: choosing what to merge (merge selectors, merge predicates, part collectors)... pr-improvement Pull request with some product improvements 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.

Small parts are left without ever merging near partition boundary

3 participants