Skip to content

Report object storage disk as local when it is using local object storage - #110665

Merged
Michicosun merged 33 commits into
masterfrom
proper_is_remote_for_object_stoarge_disks
Sep 22, 2026
Merged

Michicosun merged 33 commits into
masterfrom
proper_is_remote_for_object_stoarge_disks

Conversation

@Michicosun

@Michicosun Michicosun commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

This patch changes the isRemote outcome for DiskObjectStorage over local object storage and improves local paths check for complex disks.


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

Version info

  • Merged into: 26.10.1.422-master (included in 26.10 and later)
  • Backported to: 26.9.36.2, 26.8.44.2, 26.3.69.4

@clickhouse-gh

clickhouse-gh Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b363814]

Summary: ✅


AI Review

Summary

This PR makes DiskObjectStorage::isRemote() depend on the actual object/metadata backends and moves custom_local_disks_base_directory checks into the concrete disk factories. The remaining concerns are the same high-impact ones raised earlier in review: the local-path confinement is still bypassable in one fresh-create path and one reload path, and flipping isRemote() changes durability and read-path heuristics far beyond the system.disks.is_remote label.

PR Metadata

Changelog category should not be Not for changelog: this changes user-visible disk() validation and the reported/acted-on remoteness of local_blob_storage. Improvement is a better fit, and that category requires a user-facing entry.

Suggested replacement:

### Changelog category (leave one):
- Improvement

### Changelog entry:
Dynamic `local_blob_storage` disks now report `is_remote = 0`, and custom disk creation performs additional local-path validation for local and object-storage disks.
Findings

❌ Blockers

  • [src/Disks/DiskObjectStorage/MetadataStorages/MetadataStorageFactory.cpp:143-150] [dismissed by author -- https://github.com/Report object storage disk as local when it is using local object storage #110665#discussion_r4014967071] Omitting metadata_path still bypasses custom_local_disks_base_directory: the implicit metadata root is hardcoded to <path>/disks/<name>/, and the new check only runs when metadata_path was explicit. So disk(type = 's3', ...) or disk(type = 'local_blob_storage', path = '...') can still create local metadata outside the configured sandbox on a fresh CREATE TABLE. Suggested fix: validate the computed default path too, or derive the implicit metadata root from custom_local_disks_base_directory.
  • [src/Disks/DiskObjectStorage/DiskObjectStorage.cpp:523-529; src/Storages/MergeTree/MergeTreeData.cpp:9597; src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp:612; src/Disks/IDisk.cpp:212-215; src/Disks/DiskObjectStorage/ObjectStorages/Local/LocalObjectStorage.cpp:585-590] [dismissed by author -- https://github.com/Report object storage disk as local when it is using local object storage #110665#discussion_r4013881870] Changing local_blob_storage to look local enables the fsync_after_insert / fsync_part_directory branches, but DiskObjectStorage still inherits a no-op getDirectorySyncGuard() and LocalObjectStorage still just create_directories() for blob parents without syncing them. That means an acknowledged insert or restore can still lose new dentries after power loss even when the table explicitly enabled the fsync settings. Suggested fix: either keep a separate capability for “POSIX-durable local disk” or implement real sync guards for both metadata and blob trees before isRemote() flips.

⚠️ Majors

  • [src/Disks/DiskFromAST.cpp:102-107; src/Disks/DiskObjectStorage/RegisterDiskObjectStorage.cpp:33-34,79-80; src/Disks/DiskLocal.cpp:812-813] [dismissed by author -- https://github.com/Report object storage disk as local when it is using local object storage #110665#discussion_r4038872422] The new confinement checks still run only when the disk definition is treated as fresh input. On metadata replay (FORCE_ATTACH, restart, UNDROP), run_local_paths_check is disabled and the disk name/path validation is skipped, so previously stored escaped or out-of-base custom disk definitions still load and recreate their directories. Suggested fix: enforce the same traversal/path checks when replaying stored disk(...) ASTs, or reject/sanitize invalid legacy definitions before constructing the disk.
  • [src/Disks/DiskObjectStorage/DiskObjectStorage.cpp:523-529; src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp:322-324; src/Storages/MergeTree/MergeTreeReaderWide.cpp:114-118; src/Storages/MergeTree/MergeTreeReadPoolBase.cpp:163-175] [dismissed by author -- https://github.com/Report object storage disk as local when it is using local object storage #110665#discussion_r3664518594] This still changes more than the system.disks.is_remote label. local_blob_storage parts now stop reporting isStoredOnRemoteDisk(), so prefetch selection and the remote-read task-sizing heuristic switch from remote_fs_settings to local_fs_settings, even though DiskObjectStorage::prepareRead() still goes through the object-storage/remote-fs pipeline. The result is a silent behavior/performance change for the same disk shape, with no dedicated compatibility layer or focused regression proving it is intentional. Suggested fix: keep a separate capability for “uses the object-storage read path”, or preserve the old isStoredOnRemoteDisk() behavior for these disks.
Tests
  • ⚠️ Add a focused regression where custom_local_disks_base_directory differs from <path>/disks/ and metadata_path is omitted; the current 05212_custom_disk_local_paths_confined.sh coverage still expects that bypass to succeed.
  • ⚠️ Add a restart / FORCE_ATTACH regression proving that a previously stored invalid dynamic disk definition is rejected or sanitized on reload.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions are to close the fresh-create bypass for implicit metadata paths, enforce the same confinement rules on metadata replay (or reject invalid legacy definitions before disk construction), and decouple the isRemote() flip from the local durability / remote-read heuristic branches unless local_blob_storage also gains the missing local-disk sync semantics.

LLVM Coverage Report

Measured on commit b363814.

Metric Baseline Current Δ
Lines 88.00% 88.00% +0.00%
Functions 91.80% 91.70% -0.10%
Branches 79.30% 79.30% +0.00%

Changed lines: Changed C/C++ lines covered: 198/229 (86.46%) · 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 Jul 16, 2026
Comment thread src/Disks/DiskType.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.20% 86.20% +0.00%
Functions 92.00% 91.90% -0.10%
Branches 78.40% 78.20% -0.20%

Changed lines: Changed C/C++ lines covered: 41/65 (63.08%) · Uncovered code

Full report · Diff report

@Michicosun Michicosun closed this Jul 31, 2026
@Michicosun Michicosun reopened this Sep 14, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-object-storage-disks Object-storage disk layer: DiskObjectStorage, metadata storage adapters, transaction support for ... label Sep 14, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 29, 2026
Since ClickHouse#110665 a custom disk with
`object_storage_type = local` must live under `custom_local_disks_base_directory`,
otherwise `CREATE TABLE ... disk = disk(...)` fails with `BAD_ARGUMENTS` ("Base
path for custom local disks must be defined in config file"). The three
`SYSTEM RESTART DISK` tests of `test_part_loading_tree_rollback` create such
disks and errored at fixture setup after merging master. Point the setting at
the directory the tests already use, as `test_attach_backup_from_s3_plain`
does for its local disk.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Oct 6, 2026
The tests of #119850 also cover behaviour that came from
#110665, which was not
backported to 26.8 (its cherry-pick was closed). In 26.8 the
`custom_local_disks_base_directory` check of a disk defined in SQL runs
after the disk is registered and its directory created, does not cover
object storage disks over the local filesystem (they are reported as
remote), and exempts a disk named `backup`.

Keep the part that this backport fixes: `ALTER TABLE ... MODIFY SETTING
disk = disk(...)` with a local path outside the base directory is now
rejected, and the settings constraints still compare the resolved disk.
Drop the checks of registration and directory creation, the object
storage cases, and the integration test for a `locations` child with a
local backend, which all depend on #110665.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=124151&sha=1348e3964bcfa0dfa2569720e5461b11401f7b5b&name_0=BackportPR
PR: #124151

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Oct 6, 2026
26.7 does not have #110665, so the
`custom_local_disks_base_directory` fence still runs in `getOrCreateCustomDisk`
after the disk is created, skips object storage disks over the local filesystem,
and exempts a disk named `backup`. The cases that depend on that change (local
object storage, `metadata_path`, the `backup` name, and the integration case for
a `locations` child of type `local`) are dropped, and the stateless test checks
only that the `ALTER` is rejected, not that nothing is left behind.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=124150&sha=da3fccc21af70c4f21ec0718646f39d45812d15a&name_0=BackportPR
#124150

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 Oct 9, 2026
alexbakharew added a commit that referenced this pull request Oct 14, 2026
…ypick/26.7/124453

Adapted to the pre-#110665 `ObjectStorageFactory::create` signature of this
release branch: `run_remote_host_filter_check` is appended after the existing
`skip_access_check` parameter, and `registerDiskObjectStorage` names its
`custom_disk` argument to derive it. The `url.checkRemoteHostFilter` call in
`StorageS3Configuration::check` keeps this branch's `checkAndNormalizeHeaders`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
alexbakharew added a commit that referenced this pull request Oct 14, 2026
…ypick/26.8/124453

Adapted to the pre-#110665 `ObjectStorageFactory::create` signature of this
release branch: `run_remote_host_filter_check` is appended after the existing
`skip_access_check` parameter, and `registerDiskObjectStorage` names its
`custom_disk` argument to derive it. The `url.checkRemoteHostFilter` call in
`StorageS3Configuration::check` keeps this branch's `checkAndNormalizeHeaders`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
alexbakharew added a commit that referenced this pull request Oct 14, 2026
…ypick/26.9/124453

Adapted to the pre-#110665 `ObjectStorageFactory::create` signature of this
release branch: `run_remote_host_filter_check` is appended after the existing
`skip_access_check` parameter, and `registerDiskObjectStorage` names its
`custom_disk` argument to derive it. The `url.checkRemoteHostFilter` call in
`StorageS3Configuration::check` keeps this branch's `checkAndNormalizeHeaders`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
alexbakharew added a commit that referenced this pull request Oct 14, 2026
…ypick/26.3/124453

Adapted to the pre-#110665 `ObjectStorageFactory::create` signature of this
release branch: `run_remote_host_filter_check` is appended after the existing
`skip_access_check` parameter, and `registerDiskObjectStorage` names its
`custom_disk` argument to derive it. The `url.checkRemoteHostFilter` call in
`StorageS3Configuration::check` keeps this branch's `checkAndNormalizeHeaders`.

26.3 additionally lacks `ServerCredentialMarkerInjector`, `for_system_database` and
`DistributedPlanExecutor.cpp`, so `DiskFromAST::createCustomDisk` keeps its two-argument
form and only the `DiskConfigurationFlattener` is driven by `visitBottomUp`; the S3
creator computes `uri` first, so the host-filter check follows the settings line.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
alexbakharew added a commit that referenced this pull request Oct 14, 2026
Adapted to this branch, which carries #124453 on the pre-#110665 factory API:
the third `ObjectStorageFactory::create` parameter becomes
`RemoteHostFilterCheck remote_host_filter_check` next to `skip_access_check`,
and `registerDiskObjectStorage` derives it from its `attach` and `custom_disk`
arguments. `RemoteHostFilter::checkURL` keeps this branch's unmasked message
and only gains the early returns. `DatabaseFactory::Arguments` has no
`is_restore_from_backup` here, so only `isLoadingFromExistingMetadata` is added.

The backward-compatibility test starts from the pinned image `26.3.50.11`
(built 2026-10-13, before #124453 reached this branch) instead of the floating
`26.8` tag, which will soon include the check itself and would fail to create
the disks.

26.3 keeps its non-static `registerS3ObjectStorage`, its single-line
`storage_settings->loadFromQuery` call and has no `DistributedPlanExecutor.cpp`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
alexbakharew added a commit that referenced this pull request Oct 14, 2026
Adapted to this branch, which carries #124453 on the pre-#110665 factory API:
the third `ObjectStorageFactory::create` parameter becomes
`RemoteHostFilterCheck remote_host_filter_check` next to `skip_access_check`,
and `registerDiskObjectStorage` derives it from its `attach` and `custom_disk`
arguments. `RemoteHostFilter::checkURL` keeps this branch's unmasked message
and only gains the early returns. `DatabaseFactory::Arguments` has no
`is_restore_from_backup` here, so only `isLoadingFromExistingMetadata` is added.

The backward-compatibility test starts from the pinned image `26.9.18.11`
(built 2026-10-13, before #124453 reached this branch) instead of the floating
`26.8` tag, which will soon include the check itself and would fail to create
the disks.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
alexbakharew added a commit that referenced this pull request Oct 14, 2026
Adapted to this branch, which carries #124453 on the pre-#110665 factory API:
the third `ObjectStorageFactory::create` parameter becomes
`RemoteHostFilterCheck remote_host_filter_check` next to `skip_access_check`,
and `registerDiskObjectStorage` derives it from its `attach` and `custom_disk`
arguments. `RemoteHostFilter::checkURL` keeps this branch's unmasked message
and only gains the early returns. `DatabaseFactory::Arguments` has no
`is_restore_from_backup` here, so only `isLoadingFromExistingMetadata` is added.

The backward-compatibility test starts from the pinned image `26.8.26.12`
(built 2026-10-13, before #124453 reached this branch) instead of the floating
`26.8` tag, which will soon include the check itself and would fail to create
the disks.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
alexbakharew added a commit that referenced this pull request Oct 14, 2026
Adapted to this branch, which carries #124453 on the pre-#110665 factory API:
the third `ObjectStorageFactory::create` parameter becomes
`RemoteHostFilterCheck remote_host_filter_check` next to `skip_access_check`,
and `registerDiskObjectStorage` derives it from its `attach` and `custom_disk`
arguments. `RemoteHostFilter::checkURL` keeps this branch's unmasked message
and only gains the early returns. `DatabaseFactory::Arguments` has no
`is_restore_from_backup` here, so only `isLoadingFromExistingMetadata` is added.

The backward-compatibility test starts from the pinned image `26.7.29.12`
(built 2026-10-13, before #124453 reached this branch) instead of the floating
`26.8` tag, which will soon include the check itself and would fail to create
the disks.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@robot-ch-test-poll3 robot-ch-test-poll3 removed the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 21, 2026
robot-clickhouse-ci-2 added a commit that referenced this pull request Nov 21, 2026
Cherry pick #110665 to 26.3: Report object storage disk as local when it is using local object storage
robot-clickhouse added a commit that referenced this pull request Nov 21, 2026
robot-clickhouse added a commit that referenced this pull request Nov 21, 2026
Cherry pick #110665 to 26.8: Report object storage disk as local when it is using local object storage
robot-clickhouse added a commit that referenced this pull request Nov 21, 2026
robot-clickhouse added a commit that referenced this pull request Nov 21, 2026
Cherry pick #110665 to 26.9: Report object storage disk as local when it is using local object storage
robot-clickhouse added a commit that referenced this pull request Nov 21, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 21, 2026
alexey-milovidov added a commit that referenced this pull request Nov 21, 2026
Backport #110665 to 26.3: Report object storage disk as local when it is using local object storage
clickhouse-gh Bot added a commit that referenced this pull request Nov 22, 2026
Backport #110665 to 26.9: Report object storage disk as local when it is using local object storage
clickhouse-gh Bot added a commit that referenced this pull request Nov 22, 2026
Backport #110665 to 26.8: Report object storage disk as local when it is using local object storage
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-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo v26.2-must-backport v26.3-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants