Skip to content

Fix identity of dynamic disks with server credential markers - #129044

Merged
Algunenano merged 9 commits into
ClickHouse:masterfrom
Algunenano:disk-marker-identity
Nov 10, 2026
Merged

Algunenano merged 9 commits into
ClickHouse:masterfrom
Algunenano:disk-marker-identity

Conversation

@Algunenano

@Algunenano Algunenano commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

A dynamic disk declared with disk(...) is named after a hash of its definition, and the server appends credential markers (_server_credentials_allowed, _azure_server_credentials_allowed) to that definition. The markers made the identity of a disk unstable: tables created before a marker existed could not share or re-attach their disk after an upgrade, and on master the Azure marker made the identity depend on the session's s3_allow_server_credentials_in_user_queries, so a named disk was refused and an unnamed one was silently replaced by a new, empty disk.

  • The Azure marker is added only when the resolved disk uses the server's own Azure identity, which is exactly when a session without the opt-in is refused.
  • When a definition matches no registered disk, the forms stored by older versions are also tried: with the Azure marker (current master), without it (26.7 to 26.10) and without any marker (before 26.7). A session without the opt-in may not take a form that adds a marker.
  • A short ATTACH keeps the markers stored in the table metadata as they are.
  • A session without the opt-in can no longer use a disk with server credentials through a wrapper disk (encrypted, cache), or through a definition that resolves differently since the disk was created. This covers S3 and Azure, and every location of a multi-location disk.

A table created with the opt-in that reuses a disk declared before the markers stores the definition of that disk, so after a restart it has the same credentials as the tables already on it.

Closes: #128876
Closes: #127409
Related: #106855
Related: #120343

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

Fixed dynamic disks (disk(...) in table settings) that use from_env, from_zk or include: after an upgrade, or depending on s3_allow_server_credentials_in_user_queries, they got a different identity, so they could not be shared or re-attached, or the table was attached to a new, empty disk. A session without s3_allow_server_credentials_in_user_queries can no longer use a disk with server credentials through a wrapper disk.


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

Version info

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

A dynamic disk is named after a hash of its definition, which includes the
credential markers the server appends. The Azure marker is now added only when
the resolved disk uses the server's own Azure identity, and a definition that
matches no registered disk is also tried in the forms stored by older versions.
A short `ATTACH` keeps the stored markers. A session without
`s3_allow_server_credentials_in_user_queries` can no longer use a disk with
server credentials through a wrapper disk or a definition that resolves
differently since the disk was created.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Algunenano Algunenano added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Nov 3, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ec8919f]

Summary: ✅


AI Review

Summary

The PR preserves dynamic-disk identities across credential-marker changes, keeps stored definitions on short ATTACH, and checks credential-bearing custom disks when selected through wrappers, disk names, or storage policies. Reviewed head ec8919f744ff263d4881dd4db90bb9f6f2e6c8bf, the full diff, callers, and all prior discussion. The four earlier findings are addressed; no new actionable findings. Regression test 05494 passed locally against the PR's fast-test binary, matching all 73 expected lines, including permanent detach/attach and mixed legacy/current wrapper identities.

Missing context / blind spots
  • ⚠️ Azure and ZooKeeper-specific tests 05495 and 05496 were inspected but not executed locally; their configured CI runs remain the runtime validation for those backends.
Final Verdict

✅ Approve. No unresolved findings or new inline comments.

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-multidisk Multiple disks/volumes storage policies, disk abstractions. labels Nov 3, 2026
Comment thread src/Disks/DiskFromAST.cpp Resolved
Comment thread src/Disks/DiskFromAST.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing ec8919f74 with master 5c1a21488 (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

129 object files changed (+59.52 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Disks/DiskFromAST.cpp.o 125.32 KiB 216.21 KiB +90.89 KiB (+72.53%)
src/CMakeFiles/dbms.dir/Disks/getDiskConfigurationFromAST.cpp.o 245.29 KiB 210.80 KiB -34.49 KiB (-14.06%)

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

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

Job report

A session without `s3_allow_server_credentials_in_user_queries` could use a
disk with server credentials through its implicit `__<disk>` storage policy.
Refuse it on `CREATE`, user `ATTACH` and `ALTER ... MODIFY SETTING`.

A disk function now passes every registered disk it matches to the disk that
wraps it, so a wrapper declared by an older version is found even when the disk
of the newer form below it is registered too.

Move the paths of the `encrypted` disks in 05496 inside
`custom_local_disks_base_directory`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…LTER

`StorageFactory::Arguments::getDisk` and `getStoragePolicy` resolve a disk or a
storage policy named by a table definition and, unless the table is loaded from
existing metadata, refuse a custom disk with server credentials for a session
without `s3_allow_server_credentials_in_user_queries`. `Log`, `TinyLog`,
`StripeLog`, `Set`, `Join`, `Distributed` and the MergeTree `storage_policy`
setting use them. `ALTER ... MODIFY SETTING storage_policy` checks the policy
only when it changes.

In 05496, wrap local disks under `custom_local_disks_base_directory` and drop
every table right away, so that no table names a disk of another table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Algunenano and others added 5 commits November 4, 2026 15:04
A forbidden `storage_policy` must be reported by the constraint check, not as an unknown policy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Master now checks the effective storage policy before the per-setting loop, so the credentials check has to run there to be reported first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	src/Storages/MergeTree/MergeTreeSettings.cpp
@Algunenano
Algunenano added this pull request to the merge queue Nov 10, 2026
Merged via the queue into ClickHouse:master with commit d2a3900 Nov 10, 2026
187 checks passed
@Algunenano
Algunenano deleted the disk-marker-identity branch November 10, 2026 09:48
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 10, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 10, 2026
Algunenano added a commit that referenced this pull request Nov 10, 2026
The release has no Azure server credentials marker (#120343), so only the form without
`_server_credentials_allowed` is tried, and the Azure test is dropped. The `storage_policy`
check of `ALTER` runs in the per-setting loop of the release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Algunenano added a commit that referenced this pull request Nov 10, 2026
The release has no Azure server credentials marker (#120343), so only the form without
`_server_credentials_allowed` is tried, and the Azure test is dropped. The `storage_policy`
check of `ALTER` runs in the per-setting loop of the release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
robot-ch-test-poll2 added a commit that referenced this pull request Nov 10, 2026
Cherry pick #129044 to 26.8: Fix identity of dynamic disks with server credential markers
robot-clickhouse added a commit that referenced this pull request Nov 10, 2026
robot-ch-test-poll2 added a commit that referenced this pull request Nov 10, 2026
Cherry pick #129044 to 26.9: Fix identity of dynamic disks with server credential markers
robot-clickhouse added a commit that referenced this pull request Nov 10, 2026
robot-ch-test-poll2 added a commit that referenced this pull request Nov 10, 2026
Cherry pick #129044 to 26.10: Fix identity of dynamic disks with server credential markers
robot-clickhouse added a commit that referenced this pull request Nov 10, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 10, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 10, 2026
Backport #129044 to 26.8: Fix identity of dynamic disks with server credential markers
clickhouse-gh Bot added a commit that referenced this pull request Nov 10, 2026
Backport #129044 to 26.9: Fix identity of dynamic disks with server credential markers
clickhouse-gh Bot added a commit that referenced this pull request Nov 10, 2026
Backport #129044 to 26.10: Fix identity of dynamic disks with server credential markers
alexey-milovidov added a commit that referenced this pull request Nov 10, 2026
…s-on-detach

Conflicts with #129044, which tries older forms of a
custom disk definition (other credentials markers) and checks the disks a table names by name:
- `getOrCreateCustomDisk` keeps both the alternatives of master and the registration of this PR. The
  registrations of the disks of the first form are passed as the nested ones: if another form is
  chosen, its disk exists already, and its registration owns its own nested registrations.
- `createCustomDisk`, `loadFromQuery` and `resolveDiskSetting` take `stored_definition` and return a
  registration.
- `Log`, `StripeLog`, `Set` and `Join` use the new `StorageFactory::Arguments::getDiskWithCustomDiskRegistration`,
  which checks the disk as `getDisk` does and takes its registration together with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Nov 10, 2026
…server_credentials_disk`

The test from #129044 relied on a custom disk staying
registered after its table is dropped. With this PR, a disk is released when the last table using it
is gone, so wrapping `SERVER_DISK`, `WRAPPER_DISK` or `PLAIN_DISK` by name failed with `BAD_ARGUMENTS`
(no such disk), and the `from_zk` wrapper would have been created anew instead of being reused.
Keep the tables defining these disks until the end of the test, and drop them before it ends.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
eoger-ant pushed a commit to eoger-ant/ClickHouse that referenced this pull request Nov 11, 2026
The stress `default` profile sets `ast_fuzzer_runs = 5` and
`ast_fuzzer_any_query = true`, so every successful CREATE of
05496_dynamic_disk_wrapper_of_server_credentials_disk is replayed as
`created__fuzz_N` / `t_policy__fuzz_N`. The test drops only `created` and
`t_policy`, and the copies name by reference the disks and storage policies
(`plain_<db>`, `server_<db>`, `__plain_<db>`, `__server_<db>`) that only the
dropped tables defined, or resolve them through Keeper nodes the test removes
at the end. After the post-stress restart nothing defines those names, the
copy's metadata cannot be parsed and the server does not start
(`Cannot start clickhouse-server`, 11 Stress rows since ClickHouse#129044 merged,
including master and the 26.10 backport branch).

Stress also passes `ignore_drop_queries_probability=0.2` to every client, and
an ignored DROP of `created` or `t_policy` leaves a table that cannot be
loaded after the restart either.

Pin `--ast_fuzzer_any_query=0 --ignore_drop_queries_probability=0` on the
test's client (the same pair as 05321). With `ast_fuzzer_any_query = 0`
`executeASTFuzzerQueries` returns early for every non-read-only seed, and the
test issues only DDL. The appended values win over the stress client options
because clickhouse-test passes `--allow_repeated_settings` and the client
keeps the last occurrence.

Local reproduction with the stress fuzzer profile (debug build, CI config):
unpatched, 3 runs in a fixed database left 8 copies and the restart with
`async_load_databases = false` failed with `Code: 478 Unknown storage policy
__plain_test_1 ... created__fuzz_84.sql`; with every DROP ignored it failed
with `Code: 478 ... __server_test_1 ... t_policy.sql`. Patched: 0 copies,
0 ignored DROPs of the test's tables, the restart succeeds; 50/50 randomized
runs pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
@clickhouse-gh clickhouse-gh Bot added comp-disk-abstractions Core disk abstractions: IDisk interface, DiskLocal, storage policies, volumes, disk management to... and removed comp-multidisk Multiple disks/volumes storage policies, disk abstractions. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-disk-abstractions Core disk abstractions: IDisk interface, DiskLocal, storage policies, volumes, disk management to... 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

4 participants