Skip to content

Port masking-policy gate and Keeper component propagation in MergeTreeDataSelectExecutor - #126866

Merged
alexey-milovidov merged 4 commits into
masterfrom
upstream-select-executor-divergence
Oct 24, 2026
Merged

alexey-milovidov merged 4 commits into
masterfrom
upstream-select-executor-divergence

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

Small changes in MergeTreeDataSelectExecutor and ReadFromMergeTree, to reduce divergence with downstream forks:

  • partHasStaleTopKIndex now includes enabled masking policies in the gate that decides whether to build alter conversions and check the top-k skip index for staleness, and passes them to MergeTreeData::getAlterConversionsForPart, which takes this extra argument in builds with CLICKHOUSE_CLOUD. Previously this call missed the argument, so the code did not compile in such builds. Outside of them has_masking_policies is always false, so there is no behavior change.
  • The skip-index analysis thread pool jobs in filterPartsByPrimaryKeyAndSkipIndexes now propagate the Keeper component (Coordination::getCurrentComponent / setCurrentComponent), since ThreadGroupSwitcher does not carry it and skip-index analysis may read from a Keeper-backed disk.
  • ReadFromMergeTree treats enabled masking policies like pending mutations: it disables skip indexes on data read (supportsSkipIndexesOnDataRead) and the read-time primary-key pruning, since the on-disk index bounds describe unmasked values. Outside of CLICKHOUSE_CLOUD builds hasEnabledMaskingPolicies is always false, so there is no behavior change.
  • For the same reason, a read is not gated on a join seal (seal_gate_refiner) when masking policies are enabled, because RuntimeFilterReadRangesRefiner prunes by the on-disk primary index.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

🤖 Generated with Claude Code


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

Version info

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

…eeDataSelectExecutor`

In `partHasStaleTopKIndex`, also consider enabled masking policies (only in builds
with `CLICKHOUSE_CLOUD`), and pass them to `getAlterConversionsForPart`, which takes
this extra argument in such builds. Without it the code did not compile with
`CLICKHOUSE_CLOUD`.

In `filterPartsByPrimaryKeyAndSkipIndexes`, propagate the Keeper component into the
skip-index analysis thread pool jobs, since `ThreadGroupSwitcher` does not carry it.

This reduces divergence with downstream forks.

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

clickhouse-gh Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [174d493]

Summary: ✅


AI Review

Summary

PR #126866 propagates the Keeper component into index-analysis workers and prevents pruning masked data using physical index bounds. Reviewed head 174d49343b6d0e7dda9bc943abcade29f3218987: both previous findings are addressed, and no new actionable findings remain.

Missing context / blind spots
  • ⚠️ Masking-policy execution requires a private CLICKHOUSE_CLOUD build, unavailable in this checkout. A private regression run comparing masked top-K and join results with the affected pruning options enabled and disabled would complete runtime validation.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 20, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Oct 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 174d49343 with master eddf9eec0 (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

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

Job report

…under masking policies

A masking policy rewrites columns at read time but is not part of the mutation
snapshot, so `ReadFromMergeTree::supportsSkipIndexesOnDataRead` accepted such a
read and `MergeTreeSkipIndexReader` loaded unmasked minmax / primary index
bounds for top-K pruning, which could compare them with a threshold produced
from masked rows. Treat enabled masking policies like pending mutations: disable
skip indexes on data read and the read-time primary-key pruning (top-K and join
runtime filters). Outside of builds with `CLICKHOUSE_CLOUD`,
`hasEnabledMaskingPolicies` is always `false`, so there is no behavior change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 2 commits October 23, 2026 23:03
…cies

`RuntimeFilterReadRangesRefiner` prunes ranges by the on-disk primary index, which describes
unmasked values when a masking policy rewrites the key columns at read time. Leave such a read
ungated, so the refiner is not installed on the read pools.

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

@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 24, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 24, 2026
Merged via the queue into master with commit dc10096 Oct 24, 2026
179 checks passed
@alexey-milovidov
alexey-milovidov deleted the upstream-select-executor-divergence branch October 24, 2026 03:46
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 24, 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-not-for-changelog This PR should not be mentioned in the changelog 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