Skip to content

Require an acknowledgement for row policies on tables with a blending engine - #112817

Open
yariks5s wants to merge 41 commits into
masterfrom
yarik/row-policy-blending-engines
Open

yariks5s wants to merge 41 commits into
masterfrom
yarik/row-policy-blending-engines

Conversation

@yariks5s

@yariks5s yariks5s commented Jul 31, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Backward Incompatible Change

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

Creating or altering a row policy on a SummingMergeTree, AggregatingMergeTree, CoalescingMergeTree or GraphiteMergeTree table now requires allow_suspicious_row_policies_with_blending_engines = 1: merges put the values of hidden rows into the rows the policy shows. On these engines a row policy now applies before FINAL.


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

@yariks5s
yariks5s requested a review from a team as a code owner July 31, 2026 20:50
@clickhouse-gh

clickhouse-gh Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [96360c0]

Summary: ❌

job_name test_name status info comment
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/can_be_merged.py --review-threads FAIL

AI Review

Summary

This PR requires an explicit acknowledgement before applying row policies to blending engines and their supported wrappers, checks creation and rename paths, and applies policies before FINAL on those engines. Reviewed PR head 96360c0a04f085af5c5f36778b93131275f83274, the current code, and all prior discussion. No actionable findings remain within the documented scope. The author's documented limits concerning asynchronous loading, later-created or renamed wrapper targets, and RENAME DATABASE are accepted scope decisions.

Final Verdict

Status: ✅ Approve.

All 13 focused row-policy tests passed in the head's Fast test report, covering the acknowledgement, wrappers, metadata access, refreshes, and FINAL filtering. No local build or test execution was performed. No new inline findings or thread replies were posted.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jul 31, 2026
@yariks5s
yariks5s force-pushed the yarik/row-policy-blending-engines branch from 970dd73 to 4e8fd95 Compare July 31, 2026 21:02
@mintlify

mintlify Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Nov 15, 2026, 11:48 AM

@clickhouse-gh

clickhouse-gh Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

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

Full report · Diff report

@yariks5s
yariks5s force-pushed the yarik/row-policy-blending-engines branch from 4e8fd95 to eea2ce6 Compare August 4, 2026 19:29
@yariks5s
yariks5s force-pushed the yarik/row-policy-blending-engines branch from eea2ce6 to 90303df Compare August 4, 2026 19:51
…ending-engines

# Conflicts:
#	ci/jobs/scripts/check_style/experimental_settings_ignore.txt
#	src/Interpreters/InterpreterCreateQuery.cpp
@yariks5s yariks5s added the pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard label Sep 1, 2026
if (!db)
return;

for (auto it = db->getTablesIterator(context, {}, /*skip_not_loaded=*/ true); it->isValid(); it->next())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ON db.* is still bypassable while a database is loading asynchronously. IDatabase::getTablesIterator explicitly excludes not-yet-loaded tables when skip_not_loaded = true, and DatabaseOrdinary::getTablesIterator warns that DDL would otherwise miss tables entirely. That means a user can run CREATE ROW POLICY ... ON db.* during async_load_databases = 1 (or any other startup window with pending table loads), miss an existing SummingMergeTree / CoalescingMergeTree, and have the policy start applying to it as soon as startup finishes, without ever requiring allow_suspicious_row_policies_with_blending_engines = 1.

Could this iterate with skip_not_loaded = false, or otherwise re-check wildcard row policies before a late-loaded blending table is published?

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.

🕵 This gap exists only while the server loads the tables at startup. I do not fix it in this PR.

To close it, CREATE ROW POLICY ... ON db.* must call getTablesIterator with skip_not_loaded = false. Then DatabaseOrdinary::getTablesIterator waits until every table of the database loads, and waitLoad throws if one table fails to load. So the statement waits until the startup ends, and an unrelated broken table makes it fail. I think that is worse than the gap.

The setting is an acknowledgement for the user who runs the DDL. It is not a boundary against the user that the policy restricts. The docs say that a row policy is not a boundary on these engines, and the check covers the usual DDL paths.

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.

🕵 The docs now list this case as a limit of the check, in the section Engines which merge rows (commit 89a23d0): a table which the database did not load yet when the ON db.* policy is created is not checked. The code does not change, for the reasons in my earlier reply.

@clickhouse-gh

clickhouse-gh Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing de3d3a1ba with master 6ba6845be (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.

Object file sizes

312 object files changed (+204.31 KiB total), 1 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Interpreters/Access/checkRowPolicyForBlendingEngine.cpp.o new 102.92 KiB +102.92 KiB
src/CMakeFiles/dbms.dir/Interpreters/Access/InterpreterCreateRowPolicyQuery.cpp.o 88.70 KiB 112.07 KiB +23.37 KiB (+26.35%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

727 translation units recompiled, 5966 s compile time in total, 726 of them have a recent master baseline.

Translation units without a recent master baseline:

  • src/Interpreters/Access/checkRowPolicyForBlendingEngine.cpp: 5.9 s

Job report

@clickhouse-gh clickhouse-gh Bot added the comp-rbac Authorization: roles, grants, quotas, row-level security, access checks. label Sep 4, 2026
…ending-engines

Move the `allow_suspicious_row_policies_with_blending_engines` entry of `SettingsChangesHistory` to the current 26.10 block (26.9 is released).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ending-engines

# Conflicts:
#	src/Interpreters/InterpreterCreateQuery.cpp
yariks5s and others added 3 commits October 27, 2026 09:06
`StorageMaterializedView::prepareRefresh` creates a copy of the target, and the check of `CREATE TABLE` rejected it when a policy `ON db.*` applied, because the background refresh context does not have `allow_suspicious_row_policies_with_blending_engines`. The copy has the engine of the target, so the policy was already accepted for it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added pr-backward-incompatible Pull request with backwards incompatible changes and removed pr-improvement Pull request with some product improvements labels Nov 4, 2026
…ending-engines

# Conflicts:
#	src/Processors/QueryPlan/ReadFromMergeTree.cpp
#	src/Storages/StorageMerge.h
…d the deferral that this PR removes
…ending-engines

# Conflicts:
#	src/Storages/StorageMaterializedView.cpp

This branch was successfully deployed

1 active deployment
staging - docs — 96360c0a Deployed Nov 15, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-rbac Authorization: roles, grants, quotas, row-level security, access checks. pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard pr-backward-incompatible Pull request with backwards incompatible changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants