Skip to content

Upgrade check: judge a row policy only on tables that can be read without it - #126895

Merged
yakov-olkhovskiy merged 2 commits into
ClickHouse:masterfrom
groeneai:upgrade-check-skip-unreadable-row-policy-tables
Oct 22, 2026
Merged

yakov-olkhovskiy merged 2 commits into
ClickHouse:masterfrom
groeneai:upgrade-check-skip-unreadable-row-policy-tables

Conversation

@groeneai

@groeneai groeneai commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #126169

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Description

Upgrade check (amd_release) gave a false Cannot check whether the row policies can be applied FAIL row with the filter 1: Code: 107 ... The metadata file for Iceberg table ... doesn't exist on #126223 (report), Code: 497 ... grant SELECT for at least one column on test_1.v on two other PRs (report, report).

Root cause. An interrupted 02703_row_policy_for_database.sh leaves ON test_1.* USING 1 in the stress database, where 04894_iceberg_partition_transform_names.sh leaves IcebergLocal tables whose files its EXIT trap deleted, and 03322_view_over_parameterized_view.sql leaves the parameterized view v. A parameterized view has no columns until its parameters are given: SELECT 1 FROM v fails the access check for any user, and a filter naming a column fails with an unknown identifier, which dropped valid policies. The check added in #126169 ran only with the filter, so it could not tell a table's failure from the filter's.

Change. Parameterized views are not checked. The batched check stays the fast path. When it fails with an analysis error or the error of a data lake table without files (107 for Iceberg, 742 for Delta Lake), each table is checked with and without the filter. A table that fails the same way without the filter is logged to unreadable_row_policy_tables.txt and skipped; a filter that fails on a readable table is classified as before; anything else is still a FAIL row.

Validation. Locally on 26.9.19.9, each CI case gives the FAIL row before the change and none after, and a valid column filter next to a parameterized view is kept. A broken filter next to such a table or view is still dropped, in every table order. The #126169 cases give the same 32 dropped and 20 kept policies. 300 tables: +0.5 s, or 19 s when one has no files.


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

Version info

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

…hout it

The stress phase can leave a database-level policy (`ON test_1.* USING 1`,
from an interrupted 02703) over a database where another test left a data
lake table without files (04894 deletes them in an `EXIT` trap). The
row-policy check stopped on that table with `Code: 107 FILE_DOESNT_EXIST`,
which is not a filter error, and wrote a false `Cannot check whether the row
policies can be applied` FAIL row (seen on ClickHouse#126223).

The batched check of all covered tables stays the fast path. When it fails
with an analysis error or 107, the tables are checked one by one, with and
without the filter: a table that fails the same way without the filter is
logged to `unreadable_row_policy_tables.txt` and skipped, a filter that fails
on a readable table is classified as before, anything else is a FAIL row.
A `DeltaLakeLocal` table without files fails with `Code: 742
DELTA_KERNEL_ERROR` instead of 107 and is handled the same way.

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

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review in 2 rounds by an independent model (engine: codex; 2 findings in round 1, 0 in round 2) plus my own cold review (1 major, 2 nits).

# Sev Finding Verdict Evidence / action
1 ❌ A Delta Lake table without files fails with another code than Iceberg's 107, so the same red remains AGREE fixed: measured Code: 742 DELTA_KERNEL_ERROR on 26.9.19.9 (with and without the filter, before and after a restart), added next to 107. It never drops a policy
2 ⚠️ The fallback can overrun its 5-minute deadline DISAGREE the overrun needs both probes of the last table to hang to timeout 1m, and that table is a FAIL row anyway. A probe takes ~60 ms (305 calls in ~19 s), and the bound stays 7 min per policy
3 ⚠️ No proof of the fallback DISAGREE local transcript on 26.9.19.9: revert gives the 107 (and 742) FAIL row; fix skips the table, drops a broken filter in both orders, and keeps the FAIL row for a subquery over the table and for memory limits; the #126169 cases are identical (32 dropped / 20 kept)
4 💡 PR body wording (deadline, Iceberg vs Delta Lake) AGREE fixed

Also checked by code reading on 26.9: a Delta Lake table made with allow_delta_kernel_rs = 0 is re-read with the default kernel path (742), and a PaimonLocal table without files fails with 107 or not at all.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. 26.9.19.9 server, a database with a MergeTree table and an IcebergLocal table whose directory was deleted (made like 04894), CREATE ROW POLICY ... ON db.* USING 1 TO ALL, then the extracted row-policy block of upgrade_runner.sh: the CI FAIL row (Code 107 on DESCRIBE TABLE view(SELECT 1 FROM db.ice WHERE 1)) on every run.
b Root cause explained? Yes. A leaked ON test_1.* USING 1 policy covers a data lake table whose files its test deleted; the batched check stops on that table with 107, which is not a filter error, and the check only ever ran with the filter, so it could not tell the two apart.
c Fix matches root cause? Yes. When the batch fails with an analysis error or the error of a data lake table without files (107 for Iceberg, 742 for Delta Lake), each table is checked with and without the filter; only a failure that depends on the filter is judged. Neither 107 nor 742 ever drops a policy, and an operational failure of either check is still a FAIL row.
d Test intent preserved / new tests added? Test infrastructure change: no self-test of the runner (per #119766). Validated locally against the 26.9.19.9 release, before and after, with fault injection.
e Both directions demonstrated? Yes. Same seed: before, the FAIL row with 107; after, 0 FAIL rows, the USING 1 policies kept, a broken x = 1 filter in a database with such a table dropped in both table orders. The same for a DeltaLakeLocal table without files (742 before, 0 FAIL rows after).
f Fix is general across code paths? Yes. Iceberg (107) and Delta Lake (742) tables without files, also both in one database; database-level and table-level policies on such a table, and a filter subquery reading it (still a FAIL row: the table check passes). This block is the only row-policy check in the CI scripts.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes. Dangling table before or after the readable ones; 1 to 300 covered tables; the 52 policies of the #126169 cases (quoted names, ALL EXCEPT, user-scoped, subqueries) give identical dropped and kept lists.
h Backward compatible? (maintainer-approved exception only) Yes. CI script only; previous outcomes unchanged on every #126169 case; the generator query runs on the previous release (26.9.19.9 measured).
i Invariants and contracts preserved? Yes. A policy is dropped only when its filter fails on a table that passes without it; a memory limit on either check, a dead server, a failed DROP generation and the per-policy 5-minute deadline all keep the policies and give a FAIL row; the block completes under set -ex in every case.

Session id: cron:clickhouse-impl-slot-5:20261020-072500

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @fm4v, could you review this and add the can be tested label so CI runs? When the batched row-policy check of the Upgrade check fails with the error of a data lake table without files (107 for Iceberg, 742 for Delta Lake), it now re-checks each covered table with and without the filter and skips the tables that fail without it, so an unreadable table no longer gives the Cannot check whether the row policies can be applied FAIL row.

@clickhouse-gh

clickhouse-gh Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0b11081]

Summary: ✅


AI Review

Summary

The upgrade check now distinguishes row-policy filter failures from failures of the covered table and excludes parameterized views from these probes. No actionable findings in 0b11081764c8542a158ddc0655697eaef51542e6. The documented before/after reproductions and 14 passing shell contract cases support approval.

Missing context / blind spots
  • ⚠️ The full upgrade run was not repeated here; the shell checks used mocked client responses and did not execute SQL. No completed Upgrade check (amd_release) results were available for this head. A completed run would provide independent end-to-end confirmation of the author's recorded local validation.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 20, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Oct 20, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 21, 2026
`03322_view_over_parameterized_view` leaves the parameterized view `test_1.v`
and an interrupted `02703_row_policy_for_database` leaks `ON test_1.* USING 1`.
A parameterized view has no columns until its parameters are given, so
`SELECT 1 FROM v` fails the access check for any user (Code 497), and a filter
naming a column fails with an unknown identifier, which dropped a valid policy.
Red on ClickHouse#126880 and ClickHouse#127094.

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

Copy link
Copy Markdown
Collaborator Author
Internal second-model review of 0b11081: adjudication log (click to expand)

Pre-publication review of the added commit in 1 round by an independent model (engine: codex; 0 findings) plus my own cold review (2 nits, PR text only).

# Sev Finding Verdict Evidence / action
1 💡 The description named an unrelated PR by number AGREE fixed: it links the two CI reports instead
2 💡 The commit message does the same AGREE noted, not blocking (text only)

Also checked by code reading: a parameterized view is the only table kind without stored columns (CREATE refuses a table without physical columns), and an Alias whose target is gone fails with 60 with and without the filter, which the previous commit already skips. Reading parameterized_view_parameters costs ~3 ms per policy over 5,577 tables on 26.9.19.9.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Added 0b11081764c85: parameterized views are no longer checked. A parameterized view has no columns until its parameters are given, so the check failed with Code 497 for any user (the red Upgrade check on two other PRs), and a filter naming a column failed with an unknown identifier, which dropped a valid policy.

Copilot AI left a comment

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.

🟢 Approval recommended

The focused change preserves policy classification and unexpected-error reporting, with no unresolved findings.

No open issues 🎉

What changed in this PR

This PR refines the upgrade check introduced in #126169 so unreadable leftover tables do not cause false row-policy failures.

Changes:

  • Excludes parameterized views from row-policy checks.
  • Preserves the batched fast path, then compares filtered and unfiltered checks after selected failures.
  • Logs unreadable tables while retaining invalid-filter detection and unexpected-error reporting.
File Description
tests/​docker_scripts/​upgrade_runner.sh Adds per-table comparison and diagnostics to distinguish table failures from invalid row-policy filters.

Review effort: Balanced

@yakov-olkhovskiy
yakov-olkhovskiy added this pull request to the merge queue Oct 22, 2026
Merged via the queue into ClickHouse:master with commit 4a262f8 Oct 22, 2026
178 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 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-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). manual approve Manual approve required to run CI pr-ci 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.

5 participants