Skip to content

Fix ATTACH for S3 disks created without 'remote_url_allow_hosts - #124930

Merged
alexbakharew merged 8 commits into
masterfrom
abakharew/custom-disk-remote-host-filter-on-load
Oct 13, 2026
Merged

alexbakharew merged 8 commits into
masterfrom
abakharew/custom-disk-remote-host-filter-on-load

Conversation

@alexbakharew

@alexbakharew alexbakharew commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

closes: #124872

Changelog category (leave one):

  • Bug Fix

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

Fixed loading, short ATTACH, and UNDROP TABLE for existing SQL-defined S3 disks whose endpoints are absent from remote_url_allow_hosts; new full-definition CREATE and ATTACH still reject disallowed endpoints.


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

Version info

  • Merged into: 26.10.1.2314-master (included in 26.10 and later)
  • Backported to: 26.9.19.15, 26.8.28.7, 26.7.31.9, 26.3.52.10

@alexbakharew
alexbakharew requested a review from scanhex12 October 9, 2026 14:23
@mintlify

mintlify Bot commented Oct 9, 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 Oct 13, 2026, 11:51 AM

@clickhouse-gh

clickhouse-gh Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2e8c3b0]

Summary: ✅


AI Review

Summary

This PR narrows the remote_url_allow_hosts regression for SQL-defined S3 disks from a hard failure to a warn-and-continue path when the server is replaying metadata at startup, and it now covers the dropped-table / UNDROP TABLE path as well. High-level verdict: the startup and UNDROP parts look good, but the manual short-ATTACH path is still left on the hard-fail behavior, so the linked regression and the PR’s own changelog entry are not fully fixed.

PR Metadata
  • Changelog category: Bug Fix is correct for the user-visible regression this PR is addressing.
  • Changelog entry: required, but the current text is inaccurate. It says short ATTACH is fixed, while the new regression test explicitly expects ATTACH TABLE t_detached to keep throwing UNACCEPTABLE_URL at tests/integration/test_backward_compatibility/test_custom_s3_disk_remote_url_allow_hosts.py:100.
  • Exact replacement text: Existing SQL-defined S3 disks whose endpoints are absent from remote_url_allow_hosts no longer block server startup; they load with a warning in the log and system.warnings, and UNDROP TABLE continues to work. New CREATE and user ATTACH queries still reject disallowed endpoints.
Findings
  • ⚠️ Major — [src/Storages/MergeTree/registerStorageMergeTree.cpp:955, src/Databases/DatabaseFactory.cpp:77] [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/124930#discussion_r4231481722] The PR still treats short ATTACH that has to rebuild a stored SQL-defined S3 disk as fresh user input for the disk check. That means a table parked with DETACH TABLE ... PERMANENTLY still fails on the first ATTACH TABLE after the upgrade, and any ATTACH DATABASE path that has to recreate its metadata disk goes through the same create-like enforcement. Startup and UNDROP now recover, but manual re-attach of existing metadata still requires editing remote_url_allow_hosts, which is the remaining half of the linked regression. Suggested fix: split the remote-host-filter exemption from the broader is_loading_from_existing_metadata gate, and apply the relaxed/warn-only behavior only to the host-filter check for definitions that were previously stored by this server.
Final Verdict

Changes requested: the startup / UNDROP fix is solid, but the PR still does not fully fix the existing-metadata ATTACH regression it is linked to, and the changelog entry currently overstates the behavior.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 9, 2026
@alexbakharew
alexbakharew requested a review from jkartseva October 9, 2026 14:25
@scanhex12 scanhex12 self-assigned this Oct 9, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-object-storage-disks Object-storage disk layer: DiskObjectStorage, metadata storage adapters, transaction support for ... label Oct 9, 2026
alexbakharew and others added 2 commits October 9, 2026 18:45
… for the disk check

Two paths still enforced `remote_url_allow_hosts` on definitions that the
server stored itself:

- Databases at server start. `loadDatabase` runs the stored `ATTACH DATABASE`
  with `create = true`, so `setForceAttach` is skipped and the mode is `ATTACH`,
  not `FORCE_ATTACH`. The server did not start in CI with a database whose
  metadata disk points to an endpoint outside the list. The signal for this
  path is `is_metadata_replay`.
- A short `ATTACH TABLE t` or `ATTACH DATABASE db` reads the definition back
  from the metadata file and marks it with `attach_short_syntax`, while the
  mode is `ATTACH`.

`DatabaseFactory::Arguments::isLoadingFromExistingMetadata` combines the mode,
`is_metadata_replay` and `attach_short_syntax` for the database metadata disk.
`registerStorageMergeTree` adds `attach_short_syntax` to the mode for tables.
A user `ATTACH` with a full definition keeps `attach_short_syntax` false and
stays enforced.

The log line, the `system.warnings` text, the comments and the docs name the
third event.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…`DETACH PERMANENTLY`

In an `Atomic` database a full-definition `ATTACH TABLE` needs a `UUID`;
without it the query fails with `INCORRECT_QUERY` before the disk is built,
which is what CI reported. The case now passes a `UUID` and expects
`UNACCEPTABLE_URL`.

A table detached permanently before the upgrade has no disk at server start,
so the short `ATTACH TABLE t_detached` on the new binary is the first creation
of its disk: it must be accepted and reported. The database case adds a
`DETACH DATABASE` / `ATTACH DATABASE` cycle and uses the default restart wait.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 2e8c3b098 with master 5b5a054df (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

104 object files changed (+57.09 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Disks/DiskObjectStorage/ObjectStorages/ObjectStorageFactory.cpp.o 178.83 KiB 234.55 KiB +55.73 KiB (+31.16%)

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

1335 translation units recompiled, 8416 s compile time in total, 1335 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 Oct 12, 2026
alexbakharew and others added 2 commits October 13, 2026 12:30
…rt and `UNDROP`

The previous commit set the `is_loading_from_existing_metadata` flag for a
short `ATTACH TABLE t` / `ATTACH DATABASE db`. That flag is shared by every
custom-disk check (`dynamic_disk_allow_*`, the server-credentials marker,
the local-paths check, the disk-name and settings-hash checks), so the change
silenced all of them for the short form, not only the host filter.

The host filter now follows the other disk checks: skipped when the server
replays metadata it stored itself, at start (`is_metadata_replay`, mode
`FORCE_ATTACH` / `FORCE_RESTORE`) and on `UNDROP`, enforced for every user
`ATTACH`, short or with a definition. A table parked with
`DETACH ... PERMANENTLY` before the upgrade gets `UNACCEPTABLE_URL` on its
first `ATTACH` until the operator adds the `<s3_bucket>` entry; `DETACH` and
`ATTACH` in a running server reuse the disk built at start and are not
affected.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…er the entry is added

The permanently detached table now expects `UNACCEPTABLE_URL` on its first
`ATTACH`, consistent with `CREATE` and with a full-definition `ATTACH`. The
test then adds `<s3_bucket>minio1:9001/root</s3_bucket>` to the allow-list,
reloads the config and attaches the table without a restart. The
`DETACH DATABASE` / `ATTACH DATABASE` cycle stays as a check that a reused
metadata disk is not re-validated.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
A table dropped before the upgrade stays in the drop queue and is rebuilt at
server start from `metadata_dropped` under `FORCE_RESTORE`. The test drops a
table on a third disk before the restart, checks that two disks were reported,
and runs `UNDROP TABLE` on the new binary. The drop delay is raised to one hour
in the test config so the queue survives a slow restart under sanitizers. The
docs sentence now says what the code does: the exemption is the rebuild at
start, which is what keeps `UNDROP TABLE` working.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
robot-clickhouse added a commit that referenced this pull request Oct 14, 2026
robot-ch-test-poll added a commit that referenced this pull request Oct 14, 2026
Cherry pick #124930 to 26.7: Fix ATTACH for S3 disks created without 'remote_url_allow_hosts
robot-clickhouse added a commit that referenced this pull request Oct 14, 2026
robot-ch-test-poll added a commit that referenced this pull request Oct 14, 2026
Cherry pick #124930 to 26.8: Fix ATTACH for S3 disks created without 'remote_url_allow_hosts
robot-clickhouse added a commit that referenced this pull request Oct 14, 2026
robot-ch-test-poll added a commit that referenced this pull request Oct 14, 2026
Cherry pick #124930 to 26.9: Fix ATTACH for S3 disks created without 'remote_url_allow_hosts
robot-clickhouse added a commit that referenced this pull request Oct 14, 2026
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 14, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 14, 2026
Backport #124930 to 26.9: Fix ATTACH for S3 disks created without 'remote_url_allow_hosts
clickhouse-gh Bot added a commit that referenced this pull request Oct 14, 2026
Backport #124930 to 26.8: Fix ATTACH for S3 disks created without 'remote_url_allow_hosts
clickhouse-gh Bot added a commit that referenced this pull request Oct 14, 2026
Backport #124930 to 26.7: Fix ATTACH for S3 disks created without 'remote_url_allow_hosts
alexbakharew added a commit that referenced this pull request Oct 15, 2026
Backport #124930 to 26.3: Fix ATTACH for S3 disks created without 'remote_url_allow_hosts
@alexbakharew alexbakharew added pr-must-backport Pull request should be backported intentionally. Use this label with great care! and removed pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Oct 15, 2026
Algunenano pushed a commit to Algunenano/ClickHouse that referenced this pull request Oct 16, 2026
….8.26.12

The test needs an old server that does not check SQL-defined disks against
`remote_url_allow_hosts`, and took it from the moving tag
`clickhouse/clickhouse-server:26.8`. Since `26.8.28.14` (2026-10-15) that tag
contains the 26.8 backports of ClickHouse#124453 (ClickHouse#125789) and ClickHouse#124930 (ClickHouse#125821), so the
old server rejects the test's first setup CREATE with `Code: 491
UNACCEPTABLE_URL` before any upgrade, and both tests fail on master.

Pin both instances to `26.8.26.12`, which predates both backports. This makes
the file byte-identical to the 26.8 branch copy, which already pins this tag.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PedroTadim added a commit to groeneai/ClickHouse that referenced this pull request Oct 17, 2026
…rl-allow-hosts

Resolve the conflict with ClickHouse#124930, which replaced
the `bool` remote host filter flag with `RemoteHostFilterCheck`. Query-created Azure disks now
follow the same policy as S3 disks: a rejection throws for `Enforce` (a query) and is only
reported for `Warn` (existing metadata at server start or `UNDROP`), through the same log line
and `system.warnings` entry, generalized to name an `<s3_bucket>` or `<host>` entry.

`test_endpoint_host_filter_on_restart` now expects the table to load with the warning after a
restart, and a new disk on the same host to be rejected.

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

This branch was successfully deployed

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

Labels

comp-object-storage-disks Object-storage disk layer: DiskObjectStorage, metadata storage adapters, transaction support for ... 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-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.3-must-backport v26.8-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow-list check on SQL S3 disks runs at ATTACH: upgrade breaks table/DB load

6 participants