Skip to content

Enforce parent table row policy in mergeTreeProjection table function - #112329

Merged
yariks5s merged 24 commits into
masterfrom
yarik/mergetree-projection-rls-53773
Aug 17, 2026
Merged

yariks5s merged 24 commits into
masterfrom
yarik/mergetree-projection-rls-53773

Conversation

@yariks5s

@yariks5s yariks5s commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

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

Fixes cases where row policy was not used for MergeTree Projections during query execution.

Version info

  • Backported to: 26.7.4.52, 26.6.3.53, 26.5.8.3, 26.3.20.7, 25.8.34.10

@clickhouse-gh

clickhouse-gh Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5f4e00f]

Summary: ✅


AI Review

Summary

This PR moves mergeTreeProjection row-policy enforcement into the analyzer/read path, refuses cases where the projection cannot safely preserve parent-row semantics, and adds broad functional coverage for those contracts. One blocker remains: the new stale-projection guard still lets lightweight-delete masks disappear before the projection read, so a deleted row can resurface if it also passes the parent row policy.

Findings
❌ Blockers
  • [src/Storages/MergeTree/StorageFromMergeTreeProjection.cpp:131,153] The new stale-read guard only checks hasDataMutations() and hasPatchParts(), but the projection read still passes snapshot_data.mutations_snapshot->cloneEmpty() into readFromParts(). cloneEmpty() drops hasLightweightDeletedMask(), and the MergeTree reader only installs the _row_exists lightweight-delete filter when that flag survives into the read task. Under the default apply_deleted_mask = 1, a parent table with an unmaterialized lightweight delete can therefore still return a deleted row from mergeTreeProjection(...) if the row also satisfies the parent row policy. Either preserve lightweight-delete filtering for projection reads or fail closed when the deleted mask would apply, and add a focused regression with DELETE FROM, a row policy, and a projection read.
Final Verdict

❌ Changes requested.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.80% 86.80% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 79.20% 79.20% +0.00%

Changed lines: Changed C/C++ lines covered: 61/65 (93.85%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Jul 28, 2026
@yariks5s yariks5s changed the title Yarik/mergetree projection rls 53773 Enforce parent table row policy in mergeTreeProjection table function Jul 28, 2026
…elect ALIAS columns); add DEFAULT column coverage
… ...); keep projection-local virtuals fail-closed
Merged via the queue into master with commit 3cf78ef Aug 17, 2026
534 of 536 checks passed
@yariks5s
yariks5s deleted the yarik/mergetree-projection-rls-53773 branch August 17, 2026 19:59
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 17, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 17, 2026
clickhouse-gh Bot pushed a commit that referenced this pull request Aug 17, 2026
clickhouse-gh Bot added a commit that referenced this pull request Aug 17, 2026
Backport #112329 to 26.6: Enforce parent table row policy in mergeTreeProjection table function
clickhouse-gh Bot added a commit that referenced this pull request Aug 17, 2026
Backport #112329 to 26.7: Enforce parent table row policy in mergeTreeProjection table function
@clickgapai

Copy link
Copy Markdown
Contributor

@yariks5s @KochetovNicolai — ClickGap found the following in this PR:

Close anything that's wrong or already addressed.

yariks5s added a commit that referenced this pull request Aug 18, 2026
Cherry pick #112329 to 25.8: Enforce parent table row policy in mergeTreeProjection table function
yariks5s added a commit that referenced this pull request Aug 18, 2026
Cherry pick #112329 to 26.3: Enforce parent table row policy in mergeTreeProjection table function
yariks5s added a commit that referenced this pull request Aug 18, 2026
Cherry pick #112329 to 26.5: Enforce parent table row policy in mergeTreeProjection table function
robot-clickhouse added a commit that referenced this pull request Aug 18, 2026
robot-clickhouse added a commit that referenced this pull request Aug 18, 2026
robot-clickhouse added a commit that referenced this pull request Aug 18, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Aug 18, 2026
yariks5s added a commit that referenced this pull request Aug 19, 2026
Backport #112329 to 26.3: Enforce parent table row policy in mergeTreeProjection table function
yariks5s added a commit that referenced this pull request Aug 19, 2026
Backport #112329 to 26.5: Enforce parent table row policy in mergeTreeProjection table function
alexey-milovidov added a commit that referenced this pull request Aug 27, 2026
Backport #112329 to 25.8: Enforce parent table row policy in mergeTreeProjection table function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

6 participants