Skip to content

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

Closed
tanner-bruce wants to merge 2 commits into
ClickHouse:masterfrom
Shopify:max-age-disable-right-tail-p01
Closed

tanner-bruce wants to merge 2 commits into
ClickHouse:masterfrom
Shopify:max-age-disable-right-tail-p01

Conversation

@tanner-bruce

@tanner-bruce tanner-bruce commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Adds an opt-in MergeTree setting, merge_selector_min_age_to_disable_right_tail_heuristic, for Simple and StochasticSimple merge selectors.

When set to a non-zero value, the merge selector skips the right-tail small-part removal heuristic for candidate ranges where every part is at least that many seconds old. The default value is 0, so existing merge behavior is preserved unless the setting is explicitly enabled. This is intended to help compact old immutable partitions where the existing right-tail heuristic can leave small parts stranded near a partition boundary.

Question for reviewers

This seems like something that should be fixed more broadly than what I've done here

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 to let Simple and StochasticSimple merge selectors include old right-tail parts in merge
candidates once all parts in the candidate range are old enough.

Documentation entry:

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

Fixes #70912
Should help with #79697

@rschu1ze rschu1ze added the can be tested Allows running workflows for external contributors label May 25, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d7edb53]


AI Review

Summary

This PR adds the opt-in MergeTree setting merge_selector_min_age_to_disable_right_tail_heuristic, wires it through MergeSelectorApplier into SimpleMergeSelector/StochasticSimple, updates compatibility history and fuzz settings, and adds focused gtest coverage for the new age-threshold behavior. I found no unresolved correctness, compatibility, or test-evidence gaps in the current PR head.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label May 25, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 91.40% 91.40% +0.00%
Branches 76.60% 76.50% -0.10%

Changed lines: 98.96% (95/96) · Uncovered code

Full report · Diff report

@tanner-bruce
tanner-bruce force-pushed the max-age-disable-right-tail-p01 branch from e429e9e to c1ae085 Compare May 26, 2026 07:22
@tanner-bruce
tanner-bruce force-pushed the max-age-disable-right-tail-p01 branch from 8864950 to d7edb53 Compare May 26, 2026 09:55
@abashkeev abashkeev added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Sep 4, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! The implementation is clear. Though it will be mostly pointless without a path for testing it and enabling it by default.

@alexey-milovidov

Copy link
Copy Markdown
Member

Please enable "allow edits by maintainers", otherwise we can't merge it.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Superseded by #122638. That PR keeps your original commits, merges current master (resolving conflicts in MergeTreeSettings.cpp, MergeSelectorApplier.cpp and the gtest), and moves the settings history into the DECLARE. I could not push the resolution here because maintainer edits are disabled on the fork. Thank you for the contribution, @tanner-bruce!

@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

can be tested Allows running workflows for external contributors comp-merges Merges of data parts: choosing what to merge (merge selectors, merge predicates, part collectors)... pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Small parts are left without ever merging near partition boundary

4 participants