Skip to content

Require the SOURCES grant for Disk(...) backup locations - #117406

Merged
PedroTadim merged 5 commits into
ClickHouse:masterfrom
groeneai:fix-backup-disk-source-grant
Sep 2, 2026
Merged

PedroTadim merged 5 commits into
ClickHouse:masterfrom
groeneai:fix-backup-disk-source-grant

Conversation

@groeneai

@groeneai groeneai commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #114405

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

BACKUP ... TO Disk(...), RESTORE ... FROM Disk(...) and CREATE DATABASE ... ENGINE = Backup(..., Disk(...)) now authorize the location against the user's SOURCES grants, like the other backup engines already do. A new DISK source is added for this: writing needs WRITE ON DISK and reading needs READ ON DISK. Previously a Disk(...) location was subject to no access check at all, so a user holding BACKUP but not SOURCES could write a backup to, and read one from, any disk listed in backups.allowed_disk. Users granted SOURCES are unaffected; a user who holds BACKUP without SOURCES and uses an allowlisted disk must now be granted READ/WRITE ON DISK.

Description

#114405 made each backup engine declare the grant its location requires, checked in BackupFactory::createBackup before any I/O. The Disk engine was left returning std::nullopt, and checkSourceAccess early-returns on nullopt, so Disk(...) locations were never authorized, while the sibling File engine demanded READ/WRITE ON FILE. Both engines share creator_fn and resolveLocalBackupLocation; only the authorization differed. backups.allowed_disk is an operator-wide allowlist, not a per-user authorization, so a user with BACKUP on their own database and SOURCES revoked could restore an operator's backup.

#114405 exempted Disk because an allowlisted disk may be local, S3- or Azure-backed, so no single existing Source describes it. Deriving it from the backing store does not work: getDataSourceDescription() reports only the local location of a multi-location disk and is node-local, so it cannot authorize ON CLUSTER. A whole-source DISK target is a pure function of the query text, identical on every host; whole-source because a disk name is not a URI. GRANT SOURCES ON *.* covers it automatically, so admin grants need no update.

04776_backup_disk_source_grants covers both directions on the local-backed disk and pins that neither grant authorizes the other locator; 04775_backup_disk_source_grants_object_storage repeats that on an S3-backed disk and asserts READ ON S3 does not authorize it. 04774_backup_destination_source_grants keeps the File coverage, less the two arms that asserted the old exemption. Disk('backups', ...) is the locator most existing backup tests use, so the suites that back up as a restricted user are updated: test_backup_restore_new, test_backup_restore_on_cluster and five stateless tests. Azure- and HDFS-backed disks are uncovered: CI has no allowlisted disk of those types and the requirement does not depend on the type.


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

Version info

  • Backported to: 26.8.3.37

groeneai and others added 2 commits August 31, 2026 15:54
BackupFactory::createBackup authorizes a backup location through the
per-engine SourceAccessFn hook, but the Disk engine's hook returned
std::nullopt and checkSourceAccess early-returns on nullopt, so a
Disk(...) location was never authorized. The sibling File engine demanded
READ/WRITE ON FILE from the same shared creator_fn and
resolveLocalBackupLocation, so only the authorization differed.
backups.allowed_disk is an operator-wide allowlist rather than a per-user
authorization, so a user holding BACKUP on their own database with
SOURCES revoked could restore an operator's backup and read rows they
were denied SELECT on.

The exemption was justified by an allowlisted disk being local, S3- or
Azure-backed, so that no single existing Source describes it. That is
true, but the conclusion should have been to give the locator a source of
its own rather than to skip the check.

Two narrower alternatives were rejected on measurement. Deriving the
source from the backing store fails twice over:
getDataSourceDescription() reports only the local location while
DiskObjectStorageTransaction forks writes to every enabled location, and
it is node-local, so it cannot authorize ON CLUSTER (worker hosts do not
re-run the check under the initiating user, since
distributed_ddl_use_initial_user_and_roles defaults to false). Reusing
Source::FILE would conflate independent capabilities, letting a user
granted only READ ON FILE read every allowlisted backup disk including
object-storage-backed ones.

A whole-source Source::DISK target is a pure function of the query text,
so it is identical on every host and independent of the disk's class,
location set and future ObjectStorageType growth. It is whole-source
because a disk name is not a URI. Since the lambda ignores its
BackupInfo, authorization now strictly precedes location resolution, so
checkDiskName and checkPath cannot leak allowlist membership to an
unauthorized user, and checkSourceAccess stays free of I/O.

GRANT SOURCES ON *.* covers the new source automatically, because
AccessRightsElement::replaceDeprecated maps SOURCES to READ | WRITE with
no parameter, so only users holding specific per-source grants need the
new one.

The Disk arms shipped in 04774 pinned the exemption as correct and are
replaced, since the behaviour intentionally changed; the File arms are
unchanged. 04775 is a uniformity guard over an S3-backed disk: the
requirement provably cannot vary by backing store, so it exists to stop a
future change special-casing object storage, and it asserts that READ ON
S3 does not authorize an S3-backed backup disk.

Co-Authored-By: Claude Opus 5 <[email protected]>
Disk('backups', ...) is the locator almost every existing backup test uses,
so making READ/WRITE ON DISK a prerequisite changes what those tests need.
Seven shipped tests back up or restore as a restricted user through such a
locator and would have failed: the integration suites test_backup_restore_new
(16 sites, its new_backup_name() returns a Disk(...) locator for the whole
file) and test_backup_restore_on_cluster (11 sites), plus the stateless
04027, 04401_remote_storage_engine_restore_access,
04489_remote_storage_engine_restore_tf_access,
04401_url_engine_s3_dispatch_engine_grant and
03315_query_log_privileges_backup_restore.

Each user gets the explicit direction its test needs, granted right after the
user is created. That placement preserves every message the tests already
assert: BACKUP checks the table-level privilege before opening the backup, so
its source denial would have arrived after the object-level one, while RESTORE
opens the backup before checking access for the objects inside it, so its
source denial would have arrived first and displaced the assertion. The
per-direction grant is deliberate rather than GRANT SOURCES ON *.*, which
confers every source and could mask an unrelated assertion. In
test_backup_restore_on_cluster the grant is repeated after REVOKE ALL, which
takes it away again.

Two of the assertions would have become vacuous rather than failing, because
their matchers are broad enough to accept the outer-locator denial in place of
the inner authorization they were written to test: 04027's grep for
ACCESS_DENIED and 04401_remote's grep for ACCESS_DENIED or Not enough
privileges. Both were replayed by hand to confirm they still fail for their
original reason, and a control with the grant removed shows the reason
changing to the DISK denial.

03315 needs no grant, since its user receives current grants from default and
so retains SOURCES. Its reference changes instead: a source grant a
BACKUP/RESTORE consumes is recorded in used_privileges, which 04774's own
audit arm already pins. The values are the observed output, and under a mutant
that keeps the new AccessType but reverts the lambda they collapse back to the
previous reference exactly, so the change is the behaviour and nothing more.

04775's no-replicated-database reason was inherited from 04774, where it is
accurate because of its Backup-engine arm; this file has none. The tag is kept
because the claim could not be settled: the DatabaseReplicated job's cluster
needs a Keeper ensemble across several servers, and under a single-server
stand-in 04774 passes without its tag too, so the control cannot discriminate.
Only the inaccurate mechanism is removed from the comment.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet labels Aug 31, 2026
@groeneai

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

Pre-publication review by an independent model (engine: codex) plus my own cold review of the
resulting code, over two rounds. 12 findings; deduplicated to the 6 below, plus two PR-body items
resolved before publication.

# Sev Finding Verdict Evidence / action
1 ❌ Removing the Disk(...) exemption newly denies restricted-user backups, and Disk('backups', ...) is the locator the existing corpus uses, so shipped tests assert behaviour this change alters and were not updated AGREE, fixed in 0ec0d35 Found independently by both passes. Confirmed by measurement, not assumed: with the grants reverted the 5 integration sites fail 5/5 on the fixed binary, so CI really would have gone red. Fixed in test_backup_restore_new, test_backup_restore_on_cluster and 5 stateless tests. Re-verified in round 2 by re-enumerating the carrier set from scratch: of 23 integration files using a Disk( locator only those 2 run a backup as a restricted user, and of the 120 stateless files mentioning Disk( only the 7 touched plus 03231_restore_user_with_existing_role (admin-only, needs nothing) are user-related. No assertion was weakened. Under the mutation control the 6 grant-only edits do not fail; 03315 does, on 3 lines, and that is correct rather than weakened: its edit is a used_privileges reference, and the mutant's output is byte-identical to the pre-edit reference, so the edit is exactly the lambda's behavioural delta
2 ⚠️ OpenMode::UNLOCK also becomes authorized, and neither the visible code nor a test establishes that Disk(...) reaches that path or that WRITE ON DISK is right there DISAGREE The code in this tree establishes both. creator_fn is shared by File and Disk, and its only non-READ branch constructs a writer (BackupWriterDisk), so an UNLOCK open does write to the allowlisted disk. The classification is not new here: src/Backups/BackupSourceAccess.h is untouched by this change, landed with #114405, and already names Disk as an engine whose creator routes every non-READ mode through its writer branch. The sibling File, sharing that same creator_fn, has demanded WRITE for UNLOCK since #114405 merged, so this is symmetry rather than a new rule. It is additive too: the UNLOCK entry points carry their own privileges (ALTER_UNLOCK_SNAPSHOT, and BACKUP for the SYSTEM form), so nothing is loosened. The requested artifact cannot be produced from this repository, since unlockSnapshot and openBackupForUnlockSnapshot are declared in BackupsWorker.h and defined nowhere in it. The alternative offered, excluding UNLOCK for Disk, would diverge from File and leave UNLOCK on an allowlisted disk with no source check at all
3 ⚠️ The changelog category should be Critical Bug Fix (crash, data loss, RBAC) because the template lists RBAC there DISAGREE The template lists that category, it does not assign this class to it. #114405 is the same defect (the File/S3/Azure half of this bypass, reproduced on stable) and merged with Bug Fix (user-visible misbehavior in an official stable release) verbatim. checkSourceAccess is master-only, so Critical would advertise a released-version fix that does not exist there. Happy to switch if a maintainer prefers it
4 💡 04775 keeps no-replicated-database while its comment says no arm is known to need it AGREE, remedy declined The round-1 half is fixed: the comment no longer states a mechanism the file does not contain. Neither remaining remedy is available on the evidence. Dropping the tag would rest on a probe proven vacuous: 04775 passed under a local stand-in for that job's cluster, but so did 04774, whose tag reason is accurate, through two independent routes, so the probe cannot fail and licenses nothing. Naming a concrete incompatible behaviour would mean publishing a mechanism nobody has observed. Say the word and I will drop the tag
5 💡 7 added comments write Disk(...), DISK and new_backup_name() without inline code formatting AGREE, not changed The rulebook asks for it and the observation is right. Not changed because the alternative suggested, deleting them as obvious, would remove the only thing telling a reader why a DISK grant appears in a test about BACKUP privileges (new_backup_name is 1200 lines away), and why a second grant follows a REVOKE ALL. House style in those files is unformatted, as is the merged 04774. I will reformat them on request
6 💡 04775 restates four of 04774's Disk arms on a different disk AGREE, not changed Only its READ ON S3 arm is object-storage-specific, but the positive controls must stay or a refuse-everything regression would pass, and folding the file into 04774 would force no-fasttest onto the primary security assertions

Resolved in the PR body before publication, so not listed above: the changelog entry now names the
grant an operator must add, because #114405's merged entry states that Disk(...) destinations stay
restricted by backups.allowed_disk alone and this change reverses that; and the title now spells
the locator Disk(...), matching the body.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-48:20260831-200600

@clickhouse-gh clickhouse-gh Bot closed this Aug 31, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Aug 31, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4157d27]

Summary: ❌

job_name test_name status info comment
Performance Comparison (arm_release, master_head, 2/6) FAIL Performance dashboard
Check Results FAIL IGNORED
Docs examples FAIL
Documentation examples FAIL cidb IGNORED
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/new_tests_check.py FAIL IGNORED
Bugfix validation (functional tests, amd64) ERROR IGNORED
Bugfix validation (functional tests, aarch64) ERROR IGNORED
Bugfix validation (integration tests, amd64) ERROR IGNORED
Bugfix validation (integration tests, aarch64) ERROR IGNORED
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) ERROR
Container memory budget exceeded (/docker) ERROR cidb IGNORED

AI Review

Summary

This PR correctly wires top-level Disk(...) backup locations into the SOURCES privilege model and updates the affected tests, but one access-control path still violates the stated contract. A metadata-carried base_backup = Disk(...) in an incremental backup can still be restored through RESTORE ... ON CLUSTER without ever checking READ ON DISK under the initiating user, so I would not approve this as-is.

Findings
❌ Blockers
  • [src/Backups/registerBackupEnginesFileAndDisk.cpp:250-254] [dismissed by author -- https://github.com/Require the SOURCES grant for Disk(...) backup locations #117406#discussion_r3898626102] The new DISK source hook only helps when the Disk(...) locator is opened while a real user context is still in scope. checkAccessToExplicitBaseBackup() preflights only the query-supplied base_backup setting (src/Backups/BackupsWorker.cpp:157-173); if the base locator comes from the incremental backup's .backup metadata, RestorerFromBackup::CHECK_ACCESS_ONLY can finish after reading only the outer layer's file list and .sql metadata (src/Backups/RestorerFromBackup.cpp:148-154, src/Backups/BackupMetadataFinder.cpp:252-281, src/Backups/BackupImpl.cpp:724-845). The hidden base is then opened later in BackupImpl::getBaseBackupUnlocked() (src/Backups/BackupImpl.cpp:355-374), and internal ON CLUSTER worker legs run with no user_id, which Context::getAccess() treats as full access (src/Interpreters/Context.cpp:2454-2455; src/Interpreters/InterpreterCreateQuery.cpp:3514-3518). A user who can read the outer backup but lacks READ ON DISK can therefore still restore an incremental chain whose base is Disk(...), which breaks the PR's core RBAC guarantee.
    Suggested fix: authorize metadata-carried base locators under the initiating user before distributing the restore, not only explicit base_backup settings, and add a focused regression with an outer readable locator plus a hidden Disk(...) base.
Tests

⚠️ Add a focused regression for RESTORE ... ON CLUSTER where the outer backup is readable to the user, the incremental metadata points at base_backup = Disk(...), and the user lacks READ ON DISK. The test should fail before any worker can lazily open the base.

Final Verdict

Changes requested. The top-level Disk(...) check is correct, but the metadata-carried base-backup path still leaves an authorization bypass on clustered restores.

LLVM Coverage Report

Measured on commit 4157d27.

Metric Baseline Current Δ
Lines 88.60% 88.60% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 80.90% 80.90% +0.00%

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

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 31, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, no randomization needed: a missing check reproduces on every run. clickhouse-test 04774_backup_destination_source_grants 04775_backup_disk_source_grants_object_storage 01271_show_privileges against a Debug server. Pristine base: 3/3 FAIL. With the fix: 3/3 pass. The corpus half is equally deterministic: the five stateless carriers plus five integration sites fail on every run without their DISK grant and pass with it.
b Root cause explained? Yes. BackupFactory::createBackup authorizes a location through the per-engine SourceAccessFn hook, but the Disk engine's hook returned std::nullopt and checkSourceAccess early-returns on nullopt, so the single choke point every backup-open path flows through performed no authorization for that engine. File demanded READ/WRITE ON FILE from the same shared creator_fn.
c Fix matches root cause? Yes. The hook now returns a real target (Source::DISK, whole-source, same writer-unlock flag helper File uses), at the same layer File/S3/Azure already use. No call site changed, no guard added at a symptom site, no test weakened to accommodate it.
d Test intent preserved / new tests added? Yes. The three shipped 04774 lines that pinned the exemption were replaced because the behaviour intentionally changed; every other arm is byte-identical to master (verified programmatically: first 20 and last 18 reference lines unchanged). Added: 12 assertions in 04774, the new 04775 object-storage guard, and the 01271_show_privileges row. The seven shipped tests that exercise a Disk(...) locator as a restricted user were then given the explicit per-direction grant (never GRANT SOURCES ON *.*, which would mask unrelated assertions), and 03315's used_privileges reference was updated because a consumed source grant is recorded there. No expected_error string, reference assertion or locator was weakened, reworded or deleted, and the three broad ACCESS_DENIED matchers were each replayed by hand to confirm they still fail for their original reason, with a control showing the reason changes when the grant is removed.
e Both directions demonstrated? Yes. Pristine base RED with the predicted signature (5 arms allowed where denied is expected, 2 named-grant grep -c arms 0 instead of 1, and 2 arms showing the rejected RESTORE actually created the table); fixed binary GREEN. Both runs on Build-ID-verified binaries with SELECT lower(buildId()) asserted against the binary each time. --test-runs 50: 150 passed, 0 failed, and 350/350 over every touched stateless test. The corpus half is measured in both directions too: reverting only the added grants makes the five integration sites fail 5/5 on the fixed binary (WRITE ON DISK x6, READ ON DISK x1), and re-applying them makes it 5/5 pass.
f Fix is general across code paths? Yes. All 7 carriers reach the one hook (BackupsWorker.cpp:173, :705, :1154; BackupImpl.cpp:374; DatabaseBackup.cpp:240, :519, :542), so one lambda closes BACKUP, RESTORE, an explicit base_backup, and ENGINE = Backup attach and creation at once. Memory/Null keep nullopt because they genuinely have no external location. Generality was also checked in the other direction, over the existing corpus: every one of the 48 stateless files naming a Disk(' locator was run, and the 16 plus 11 restricted-user BACKUP/RESTORE sites in the two integration suites were enumerated and covered.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes, by construction: the target is a compile-time constant, so it cannot vary with the disk's class, its backing store, its location set, or the host. 04775 pins the object-storage case anyway over an S3-backed plain_rewritable disk, including an arm proving READ ON S3 does not authorize it. Both READ and WRITE get arms, as does the SOURCES group grant.
h Backward compatible? (maintainer-approved exception only) No format, serialization or default-setting change, so no SettingsChangesHistory.cpp entry; the new validation applies to queries, not data at rest, so it cannot fail on existing stored state. GRANT SOURCES ON *.* covers the new source automatically (AccessRightsElement.cpp:349-352 maps SOURCES to `READ
i Invariants and contracts preserved? Yes. checkSourceAccess's documented "performs no I/O" contract stays trivially true: the lambda ignores its BackupInfo. That also puts authorization strictly before location resolution, so no checkDiskName/checkPath BAD_ARGUMENTS can leak allowlist membership to an unauthorized user. backupSourceAccessFlagsForWriterUnlock is the right helper, measured not assumed: creator_fn routes every non-READ mode through the writer branch for both File and Disk. The APPLY_FOR_SOURCE/AccessType pair is mechanically required, since a member of the former with no matching enumerator fails to compile.

Anti-vacuity: with the AccessType addition kept so the grant still parses, and only the lambda body reverted to std::nullopt, exactly 7 lines move in 04774 and 4 in 04775, and every one of them is a Disk(...) arm. No File(...) arm moves, and 01271_show_privileges still passes. Under that same mutant the six grant-only corpus edits do not redden, which is the point: a grant of a source that exists but is unchecked is a no-op, so nothing was weakened to make them pass. 03315 does redden, correctly, and its mutant output is byte-identical to the pre-edit reference, so that reference edit is exactly the behavioural delta and nothing more. Both style scripts were also verified sensitive to these files by injecting a violation and confirming it was reported, since one exits 0 unconditionally and the other exits 1 when clean.

Session id: cron:clickhouse-impl-slot-5:20260831-172900

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @pufit @hanfei1991, could you review this? #114405 left the Disk engine's source-access hook returning std::nullopt, and checkSourceAccess early-returns on that, so a Disk(...) backup location is authorized by nothing while the sibling File engine sharing the same creator_fn demands READ/WRITE ON FILE; this gives the locator its own DISK source rather than deriving one from the backing store, which is node-local and so cannot authorize ON CLUSTER.

Comment thread src/Access/Common/AccessType.h Resolved
Comment on lines +250 to +254
auto disk_source_access_fn = [](const BackupInfo &, ContextPtr, IBackup::OpenMode open_mode)
-> std::optional<BackupFactory::SourceAccessTarget>
{
return BackupFactory::SourceAccessTarget{
AccessTypeObjects::Source::DISK, "", backupSourceAccessFlagsForWriterUnlock(open_mode)};

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.

This still leaves a RESTORE ... ON CLUSTER bypass for incremental chains whose outer backup is readable but whose .backup metadata carries base_backup = Disk(...). checkAccessToExplicitBaseBackup() only preflights the query setting; when the base locator comes from the manifest, the initiator's CHECK_ACCESS_ONLY pass can succeed without opening it if the incremental layer already contains the .sql metadata. The actual base is then opened lazily in BackupImpl::getBaseBackupUnlocked() on the internal DDL worker context, which by default has no user, so this new READ ON DISK check runs with full access.

Could we authorize the metadata-carried base locator under the initiating user too, and add a focused regression here (for example: outer backup on File(...) or S3(...), base backup on Disk(...), metadata changed so the outer layer keeps the .sql, then RESTORE ... ON CLUSTER without READ ON DISK)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I am not folding this into this PR. Two measurements rather than a scope argument alone.

It is not introduced here. git diff fb85d8ee6e8a..HEAD -- src/Backups/BackupsWorker.cpp src/Backups/BackupImpl.cpp is empty, and both halves of the mechanism predate this branch. checkAccessToExplicitBaseBackup, with the is_internal early return and the restore_settings-only input you describe, arrived in 02289ea070a2f14; the lazy base open in BackupImpl::getBaseBackupUnlocked arrived in 37a9e8143b5a3ba. Both are ancestors of the base fb85d8ee6e8a.

It is also not Disk-shaped. That lazy open calls BackupFactory::createBackup, which runs checkSourceAccess for whichever engine the locator names. Six engines register such a hook, and the File, S3 and AzureBlobStorage hooks all landed in 02289ea070a2f14 as well, so a cross-engine chain reaches the same code with no Disk locator involved. This change is also strictly additive: one hook moves from std::nullopt, meaning no check at all, to returning a target, so it can only cause more locators to be authorized than before, never fewer.

I did not reproduce the clustered path, so I am not claiming your mechanism is wrong. I am claiming it is neither new nor specific to this diff, which is what decides whether it belongs here. The base-chain and retained-consumer area was deliberately left out of #114405 by @ pufit, so widening into it is not something I should decide alone, and a fix there would land in files this PR does not touch.

Recording it in this thread rather than in the description, since it is a property of the merged design rather than of this change.

GRANT READ ON Disk failed with a syntax error while GRANT READ ON DISK
worked. Source names are matched case-sensitively: AccessTypeObjects
validate() looks the name up in a std::map that holds the stringified
enumerator plus the aliases declared in APPLY_FOR_SOURCE, and DISK
declared none.

Every other source whose user-facing name differs from its enumerator
registers that name (File, PostgreSQL, AzureBlobStorage, and so on), and
the ones with no alias are initialisms already spelled in uppercase (URL,
S3, HDFS, ODBC, JDBC, NATS). DISK was the only non-initialism missing
one, even though Disk(...) is exactly how the locator is written in
BACKUP and RESTORE, so the natural spelling was the one that failed.

The alias only widens the accepted input. unifySource normalizes it, so
the grant is stored and displayed as DISK, and REVOKE READ ON DISK
removes a grant made as Disk. system.privileges is unchanged, because its
aliases column is built from the AccessType enum rather than from this
table, so no privilege reference moves.

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

clickhouse-gh Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 4157d27a3 with master c90895196 (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

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

Job report

`Stateless tests (amd_asan_ubsan, flaky check)` failed this PR's head with
`Test runs too long (> 180s)` on 04774: 5 of 5 recorded runs over the gate
(183.76 to 190.85 s), no passes. That gate is per test file and fires only in
flaky-check mode (tests/clickhouse-test:3630-3646).

The cost is per client process, not per statement. 04774 was 49 client
invocations at 132.0 s p50 in ClickHouse#114405's slowest asan flaky-check job and is 75
here at 185.2 s p50: 2.69 and 2.47 s per invocation. Four interleaved local
pairs give 0.179 s per invocation on all three arms.

So the Disk section moves to 04776 with its own fixture, at 37 invocations.
04774 keeps the File coverage at 46 invocations, below the 49 it shipped with,
and its change is a pure deletion: the two arms that asserted the old `Disk`
exemption, plus the locator and admin backup only those arms used.

The moved block is verbatim apart from the local database identifier and one
added arm: `ENGINE = Backup` over a `Disk(...)` locator was asserted only in the
denied direction, here and before the split, so a regression that stopped
granting the new source on that path would not have been caught. `RESTORE` had
that positive arm already.

Equivalence is byte-exact rather than argued: dropping the two lines the new arm
prints from 04776's reference and reinserting the rest at the seam in 04774's
reproduces the published 04774 reference. With the `Disk` source hook reverted to
`std::nullopt`, 04776 fails on 7 lines and 04774 passes; with it made to demand
`WRITE` unconditionally, 04776 fails on the two positive arms.
@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

Flaky-check runtime fix

Stateless tests (amd_asan_ubsan, flaky check) failed the previous head with Test runs too long (> 180s) on 04774_backup_destination_source_grants: 5 of 5 recorded runs over the gate (183.76 to 190.85 s), no passes. The gate is per test file, and the cost here is per client process rather than per statement (49 invocations at 132.0 s p50 in #114405's own asan flaky-check job, 75 at 185.2 s p50 on the previous head).

So the Disk section moved to 04776_backup_disk_source_grants with its own fixture, at 37 invocations, and 04774 keeps the File coverage at 46, below the 49 it shipped with. Nothing was weakened: dropping the two lines the one new arm prints from 04776's reference and reinserting the rest at the seam in 04774's reproduces the previously published 04774 reference byte for byte.

The added arm is ENGINE = Backup over a Disk(...) locator with READ ON DISK granted, which had only the denied direction, here and before the split. Controls: with the Disk source hook back at std::nullopt, 04776 fails on 7 lines and 04774 passes; with the hook made to demand WRITE unconditionally, 04776 fails on both of its positive arms.

@PedroTadim PedroTadim self-assigned this Sep 1, 2026
@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - c30ed77

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Bugfix validation (functional tests, amd64) not a validation verdict: the job aborted before it ran anything, on assert build_urls, "Could not find master builds in S3" (ci/jobs/functional_tests.py:734), so nothing was validated either way #117433 (ours, open)
Bugfix validation (functional tests, aarch64) not a validation verdict: the job aborted before it ran anything, on assert build_urls, "Could not find master builds in S3" (ci/jobs/functional_tests.py:734), so nothing was validated either way #117433 (ours, open)
Bugfix validation (integration tests, amd64) not a validation verdict: the job aborted before it ran anything, on assert build_urls, "Could not find master builds in S3" (ci/jobs/integration_test_job.py:1658), so nothing was validated either way #117433 (ours, open)
Bugfix validation (integration tests, aarch64) not a validation verdict: the job aborted before it ran anything, on assert build_urls, "Could not find master builds in S3" (ci/jobs/integration_test_job.py:1658), so nothing was validated either way #117433 (ours, open)
Finish Workflow / python3 ./ci/jobs/scripts/workflow_hooks/new_tests_check.py pure cascade of the four rows above, not an independent defect: the hook reports passed: none because every per-arch Bugfix validation job errored out, so it has no verdict to read #117433 (ours, open)
Docs examples / Documentation examples date-dependent doc example, not a code regression: src/Functions/toYYYYMM.cpp documents SELECT toYYYYMM(now(), 'US/Eastern') with a hardcoded 202608, so it self-broke at the September 1 month rollover. The onset time is the proof: first CIDB row 2026-09-01 04:10:16Z, which is midnight in the documented zone rather than 00:00 UTC #117459 (ours, open)
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / Container memory budget exceeded (/docker) the shard's nested containers breach the /docker cgroup leaf, so the kernel kills processes inside it and the job errors with no test attributed. 678 rows over 318 distinct pull requests in 30 days, including 45 on master, onset 2026-08-30 #117411 / #117412 (external, open)
Upgrade check (amd_release) / Error message in clickhouse-server.log (see upgrade_error_messages.txt) a background mutation retries forever with Code: 47. DB::Exception: Unknown expression identifier naming column b where the table has only a, thrown from MutatePlainMergeTreeTask, i.e. a part still carrying a column the table has dropped. Nothing in this diff touches mutations or name resolution. Scoped to that error text the breadth is 13 rows over 13 distinct pull requests in 30 days, 0 on master, first seen 2026-08-22, against a 0-row impossible-needle control and a self-control confirming the text is present in the stored column at this head #115962 (ours, open)

One PR workflow run at this head (33471482939), no duplicate parents, 170 check-runs with
raw == uniq, and the eight rows above are exactly the eight failing check-runs, so nothing is
unaccounted for.

Session id: cron:our-pr-ci-monitor:20260901-093000

@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 4157d27a3f66b75b210de18953ca84a1d7a998c5

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / Container memory budget exceeded (/docker) the shard's nested containers breach the /docker cgroup leaf, the kernel OOM-kills processes inside it and the job errors with no test attributed #117412 (external, merged 2026-09-01T11:31:33Z)
Docs examples / Documentation examples the documented output of Function/toYYYYMM#0 was pinned to 202608, so the example self-broke at the month boundary #117459 (mine, merged 2026-09-01T13:55:50Z)
Bugfix validation (functional tests and integration tests, amd64 / aarch64), Finish Workflow / Post Hooks both per-arch jobs abort on assert build_urls, "Could not find master builds in S3", so nothing could validate and new_tests_check.py then reds the post hook #117433 (mine, open)
Performance Comparison (arm_release, master_head, 2/6) / Check Results 10 errors, 8 too long: the report's error summary names insert_statistics_uniq_v2 and group_by_dynamic_keys as too slow to run as a whole, and one query of the latter as too slow to run, which aborts the shard #117447 (mine, open)

The /docker breach is a job-level condition, not a test result. I measured #117412 ABSENT from the tree that ran, from the job's own environment rather than from git ancestry: this job was launched with CI_DIND_INIT_RESERVE=17179869184 (the 16 GiB share #117412 replaces), and so were all ten failing legs I read this tick. The probe discriminates, with a positive control: two shards launched at 14:53Z and 14:59Z carry CI_DIND_INIT_RESERVE=8589934592 (the flat 8 GiB reserve #117412 introduces) and both passed. So this is rule 3c and not rule 3d, and #117411 is not a co-owner: it was closed unmerged at 11:11:48Z in favour of #117412, whose own diff comment states the causal link.

The docs example is a trunk-wide, date-dependent break, not something specific to this PR: 226 distinct pull requests and 10 true-master runs carry it. I measured #117459 ABSENT from the tree that ran, from the failure text itself: the reported query is still the old toYYYYMM(now(), ...) form, and the string the fix introduces appears in 0 of the 164 Docs examples failure rows recorded in the last day. The control is master's own line - Docs examples is FAIL at d8aa6cab7800, which is 4 commits behind the fix and has 0 occurrences of the new string, and OK at 8627fa22f015, which is the fix's own merge commit.

The perf row is a harness condition, not a regression from this diff, which changes access checks for backup destinations and cannot alter how long a statistics or GROUP BY fixture takes to create and fill. #117447 bounds a profile run by the --profile-seconds budget it was given and catches TIMEOUT_EXCEEDED, which is the query-blows-the-cap half; #116491 (mine, open) is the reporting half that turns one failing perf test into the bare 10 errors label. Note there are 0 test-level rows for this check family in 7 days, so the condition exists only in the job result and its HTML report.

I have not merged master to pick those fixes up yet. It would not clear Mergeable Check on this head, because the Bugfix validation abort and the perf harness row both remain, and none of those fixes is merged, so a merge now would cost a full CI cycle and leave the head red on the same count. One master merge picks everything up once the remaining fixes land.

Mergeable Check reports Failed: 4 at this head, which counts only the jobs it gates on. The table above is the complete non-OK, non-SKIPPED node set of the head's praktika report, so it also covers the rows Mergeable Check does not gate.

CH Inc sync was pending at this head.

Session id: cron:our-pr-ci-monitor:20260901-163000

@PedroTadim
PedroTadim added this pull request to the merge queue Sep 2, 2026
Merged via the queue into ClickHouse:master with commit 9061229 Sep 2, 2026
166 of 175 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 2, 2026
@PedroTadim

Copy link
Copy Markdown
Member

@nikitamikhaylov this PR should be backported as well maybe

@nikitamikhaylov nikitamikhaylov added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Sep 4, 2026
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 4, 2026
robot-clickhouse added a commit that referenced this pull request Sep 4, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 4, 2026
PedroTadim added a commit that referenced this pull request Sep 4, 2026
`GRANT READ ON DISK` is a syntax error on a branch without #117406, which is
what made a Disk(...) backup location require it. No release branch has that
source yet, and without it the location is not checked at all, so the grant is
only needed where the privilege exists.
PedroTadim added a commit that referenced this pull request Sep 4, 2026
`GRANT READ ON DISK` is a syntax error on a branch without #117406, which is
what made a Disk(...) backup location require it. No release branch has that
source yet, and without it the location is not checked at all, so the grant is
only needed where the privilege exists.
PedroTadim added a commit that referenced this pull request Sep 4, 2026
`GRANT READ ON DISK` is a syntax error on a branch without #117406, which is
what made a Disk(...) backup location require it. No release branch has that
source yet, and without it the location is not checked at all, so the grant is
only needed where the privilege exists.
PedroTadim added a commit that referenced this pull request Sep 4, 2026
`GRANT READ ON DISK` is a syntax error on a branch without #117406, which is
what made a Disk(...) backup location require it. No release branch has that
source yet, and without it the location is not checked at all, so the grant is
only needed where the privilege exists.
PedroTadim added a commit that referenced this pull request Sep 4, 2026
Backport #117406 to 26.8: Require the SOURCES grant for Disk(...) backup locations
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 5, 2026
A `Disk(...)` backup location is now authorized against the DISK source
(ClickHouse#117406): the Disk backup engine's SourceAccessFn returns a real
SourceAccessTarget, so writing a backup demands `WRITE ON DISK` and
reading one demands `READ ON DISK`. This test's user holds neither, so
after merging master every statement it issues as that user stopped at
the location check before reaching the materialized-view target logic
under test: six `allowed` lines flipped to `denied`, both assertions that
the denial names the target went 1 -> 0, and the TimeSeries arm reported
`forge failed`.

Grant both halves to the test user, the spelling ClickHouse#117406 used for its own
tests. The DISK source says nothing about a view target, so the oracle is
unchanged: with the grants in place the forged restore is denied with
`SELECT, INSERT ON <db>.dst` again, and with the RestorerFromBackup
change reverted the same test file still fails on six assertion lines.
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 groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default 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