Skip to content

Revert "Revert "Require the FILE source grant for an EmbeddedRocksDB table with an explicit rocksdb_dir"" - #117665

Merged
PedroTadim merged 6 commits into
masterfrom
revert-117651-revert-117428-rocksdb-explicit-dir-file-grant
Sep 4, 2026
Merged

PedroTadim merged 6 commits into
masterfrom
revert-117651-revert-117428-rocksdb-explicit-dir-file-grant

Conversation

@PedroTadim

@PedroTadim PedroTadim commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

Reverts #117651

I just need to fix the test

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):

ENGINE = EmbeddedRocksDB(ttl, rocksdb_dir, read_only) with an explicit rocksdb_dir now requires the FILE source grant that file requires for the same directory: READ ON FILE to create such a table, plus WRITE ON FILE when read_only = 0. Previously it required no source grant, so a user holding only CREATE TABLE in a database of their own could point a table at another table's directory and read its rows. ON CLUSTER and Replicated-database DDL are not covered: the replay runs with no user. The argument-less form is unaffected. Backward incompatible for anyone already using an explicit rocksdb_dir without them.


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

Version info

  • Backported to: 26.8.3.38, 26.7.7.27, 26.6.5.49, 26.3.31.7

@clickhouse-gh

clickhouse-gh Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [026899a]

Summary: ❌

job_name test_name status info comment
Stress test (arm_release) FAIL
Logical error: Not-ready Set is passed as the second argument for function 'A (STID: 0250-3e49) FAIL cidb 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 reverts the revert of the EmbeddedRocksDB explicit-rocksdb_dir source-grant check and adds a focused stateless test for the local CREATE / ATTACH / RESTORE paths. The local-path fix is mostly in place, but the restored contract still does not hold for distributed and replicated DDL, and the new READ vs WRITE split is still derived from a stale existence probe. I would not merge this as-is.

Findings

❌ Blockers

  • [src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp:867-884, src/Interpreters/DDLTask.cpp:315-353, src/Core/ServerSettings.cpp:1171, src/Interpreters/Context.cpp:2449-2455] [dismissed by author -- https://github.com/Revert "Revert "Require the FILE source grant for an EmbeddedRocksDB table with an explicit rocksdb_dir"" #117665#discussion_r3922203466] The restored FILE grant check still does not cover every entrypoint that creates an EmbeddedRocksDB storage from a fresh definition. DDLTaskBase::makeQueryContext only preserves the initiator when distributed_ddl_use_initial_user_and_roles = 1, whose default is still false, and Context::getAccess gives full access when no user_id is attached. So CREATE TABLE ... ON CLUSTER ... ENGINE = EmbeddedRocksDB(0, 'secret_dir', 1) and DatabaseReplicated replays still bypass the new READ / WRITE ON FILE check entirely on worker legs, which is the exact privilege boundary this PR claims to restore.
    Suggested fix: authorize explicit rocksdb_dir before the query enters distributed/internal DDL, or reject fresh explicit-rocksdb_dir definitions when the local context has no user attached. This needs an integration case for the default distributed_ddl_use_initial_user_and_roles = 0 path.

⚠️ Majors

  • [src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp:269-271, 876-883] [dismissed by author -- https://github.com/Revert "Revert "Require the FILE source grant for an EmbeddedRocksDB table with an explicit rocksdb_dir"" #117665#discussion_r3914263885] The new READ vs WRITE split is still decided from fs::exists(resolved) before construction, but the constructor later unconditionally runs fs::create_directories(rocksdb_dir) on the same fresh-definition path. If the directory exists during authorization and disappears before construction, a user who had only READ ON FILE still recreates it under user_files, so the write side effect is still guarded by a stale snapshot rather than by the mutation itself.
    Suggested fix: move the “may create directory” decision to the mutation point, e.g. skip fs::create_directories for explicit read_only tables or re-check/create under the same privilege decision in the constructor.
Final Verdict

Status: ❌ Block

Minimum required actions:

  • Close the no-user ON CLUSTER / DatabaseReplicated bypass for fresh explicit rocksdb_dir definitions.
  • Make the READ vs WRITE split robust against the fs::exists / fs::create_directories race.

LLVM Coverage Report

Measured on commit 026899a.

Metric Baseline Current Δ
Lines 88.70% 88.70% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 81.00% 81.00% +0.00%

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

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Sep 2, 2026
@zlareb1

zlareb1 commented Sep 2, 2026

Copy link
Copy Markdown
Member

The test in this PR is currently byte-identical to the reverted one, so the same deterministic failure will recur: the breakage was merge skew with #117406, not flakiness — details in #117651 (comment).

Since #117406, the Disk('backups', ...) location in the RESTORE arm itself requires READ ON DISK, and that check fires before the WRITE ON FILE check the arm asserts on. So the denied leg prints NOT DENIED (the denial message is now necessary to have the grant READ ON DISK) and the allowed leg prints restore-FAILED.

The fix is one line: GRANT READ ON DISK TO ${USER} before the RESTORE arm (the arm only reads the backup location). Everything else can stay as is.

@clickhouse-gh

clickhouse-gh Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 026899aff with master fb0b23675 (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

2 object files changed (+24.95 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/RocksDB/StorageEmbeddedRocksDB.cpp.o 807.34 KiB 832.25 KiB +24.91 KiB (+3.09%)

716 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

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

Job report

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default and removed pr-not-for-changelog This PR should not be mentioned in the changelog labels Sep 3, 2026
@PedroTadim
PedroTadim enabled auto-merge September 3, 2026 14:56
@PedroTadim
PedroTadim added this pull request to the merge queue Sep 4, 2026
Merged via the queue into master with commit c031d91 Sep 4, 2026
171 of 174 checks passed
@PedroTadim
PedroTadim deleted the revert-117651-revert-117428-rocksdb-explicit-dir-file-grant branch September 4, 2026 08:41
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 4, 2026
@nikitamikhaylov nikitamikhaylov added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label 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
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 4, 2026
clickhouse-gh Bot pushed a commit that referenced this pull request Sep 4, 2026
…nt for an EmbeddedRocksDB table with an explicit rocksdb_dir""
clickhouse-gh Bot added a commit that referenced this pull request Sep 4, 2026
Backport #117665 to 26.6: Revert "Revert "Require the FILE source grant for an EmbeddedRocksDB table with an explicit rocksdb_dir""
clickhouse-gh Bot added a commit that referenced this pull request Sep 4, 2026
Backport #117665 to 26.8: Revert "Revert "Require the FILE source grant for an EmbeddedRocksDB table with an explicit rocksdb_dir""
PedroTadim added a commit that referenced this pull request Sep 4, 2026
Backport #117665 to 26.7: Revert "Revert "Require the FILE source grant for an EmbeddedRocksDB table with an explicit rocksdb_dir""
PedroTadim pushed a commit that referenced this pull request Sep 4, 2026
…nt for an EmbeddedRocksDB table with an explicit rocksdb_dir""
PedroTadim added a commit that referenced this pull request Sep 4, 2026
Backport #117665 to 26.3: Revert "Revert "Require the FILE source grant for an EmbeddedRocksDB table with an explicit rocksdb_dir""
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 11, 2026
…source grant for an EmbeddedRocksDB table with an explicit rocksdb_dir""
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 11, 2026
…source grant for an EmbeddedRocksDB table with an explicit rocksdb_dir""
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-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