Skip to content

Implement writeFileUsingBlobWritingFunction for Multi-Location Disks - #127568

Merged
Michicosun merged 2 commits into
masterfrom
blob-writing-function-multi-location
Oct 23, 2026
Merged

Michicosun merged 2 commits into
masterfrom
blob-writing-function-multi-location

Conversation

@Michicosun

@Michicosun Michicosun commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

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

This patch supports writeFileUsingBlobWritingFunction for disks with multiple configured locations.


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

Version info

  • Merged into: 26.11.1.669-master (included in 26.11 and later)
  • Backported to: 26.10.2.98, 26.9.26.11, 26.8.35.9

@clickhouse-gh

clickhouse-gh Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3d0fade]

Summary: ✅


AI Review

Summary

PR #127568 extends writeFileUsingBlobWritingFunction to copy newly written blobs to other enabled locations and record missing replicas. Reviewed head 3d0fadece7a0409072a7ff0ac1ef7a8b4d5d6645. Request changes for failed-copy cleanup, copying between independent S3 endpoints, and handling a disabled local location.

Missing context / blind spots
  • ⚠️ The Cloud MetadataStorageFromKeeper implementation and a runnable ClickHouse build are absent from this checkout. Runtime validation of replication metadata, later backfill, and restart behavior needs a focused test in the Cloud build; these behaviors were assessed through the available interfaces and callers.
Findings

⚠️ Majors

  • DiskObjectStorageTransaction.cpp:469: Failed replica copies leak uploaded blobs. A copy error escapes before registering metadata or reaching commit. The caller and transaction destructor do not invoke undo, leaving the local upload and successful replica copies unreferenced and absent from the removal queue. Repeated failed restores accumulate orphaned storage. Drain the workers and roll back on failure, following the exception handling already used by DiskObjectStorage::copyFile.

  • DiskObjectStorageTransaction.cpp:466: Independent S3 endpoints cannot complete the new replication step. The S3 implementation of copyObjectToAnotherObjectStorage supplies the destination client for both sides of copyS3File. With two independent MinIO services, B receives a request to copy A's bucket/key within B, where that source does not exist; NoSuchBucket/NoSuchKey propagates. Ordinary writeFile handles these destinations independently, but RESTORE fails. Explicitly use source-read/destination-write copying across independent services.

  • DiskObjectStorageTransaction.cpp:450: The seed upload ignores a disabled local location. Configuration permits independent local and enabled flags. Unlike ordinary writes, this path writes to the local location unconditionally, so disabling an unwritable local A while retaining healthy B still makes RESTORE fail on A. Choose an enabled seed and its corresponding callback client/namespace, or explicitly enforce and document the local-enabled requirement before uploading.

Tests
  • ⚠️ No regression coverage is added for the newly supported multi-location path. Add focused coverage proving that restored bytes reach both enabled locations, disabled locations remain missing and can later be backfilled, and one destination's copy failure removes every uploaded blob. Exercise independent S3 endpoints and the disabled-local case above. Existing single-location backup tests cannot prove these behaviors.
Final Verdict

⚠️ Request changes. Ensure failed copies clean up their uploads, handle independent S3 services correctly, settle disabled-local behavior, and provide focused multi-location regression coverage.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Oct 23, 2026
@alesapin alesapin self-assigned this Oct 23, 2026
local_object_storage->copyObjectToAnotherObjectStorage(object, object, read_settings, write_settings, *object_storages->takePointingTo(location));
});
}
runner.waitForAllToFinishAndRethrowFirstError();

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.

[P2] Roll back uploaded blobs when a replica copy fails

If one enabled destination rejects a copy after the local upload succeeds, this wait throws before the metadata operation below is registered. DiskObjectStorage::writeFileUsingBlobWritingFunction then exits before commit, and neither it nor the transaction destructor calls undo. The local blob and any successful replica copies are therefore left without metadata or a removal-queue entry, so failed/retried restores accumulate orphaned objects. Please drain the workers and roll back the uploaded blobs on this exception path, as the existing DiskObjectStorage::copyFile caller already does, and cover a failure on one destination.


runner.enqueueAndKeepTrack([&, location]
{
local_object_storage->copyObjectToAnotherObjectStorage(object, object, read_settings, write_settings, *object_storages->takePointingTo(location));

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.

[P2] Handle S3 locations on independent endpoints

This new fan-out also reaches S3ObjectStorage::copyObjectToAnotherObjectStorage, whose S3 shortcut passes the destination client as both clients to copyS3File (S3ObjectStorage.cpp:667,681–685). For enabled locations on two independent MinIO endpoints, uploading bucket-a/key on A succeeds, but the subsequent copy asks endpoint B to copy B's nonexistent bucket-a/key; it never reads the object on A. NoSuchBucket/NoSuchKey propagates rather than selecting the buffered path. Consequently, RESTORE still fails for this multi-location configuration even though ordinary writeFile writes to both endpoints. Please explicitly select source-read/destination-write copying for independent services, and add coverage with two endpoints.

object.bytes_size = std::move(write_blob_function)(blob_path, WriteMode::Rewrite, /*object_attributes=*/std::nullopt);

addOperation([object, mode](MetadataTransactionPtr tx)
LocationSet written_locations{local_location};

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.

[P2] Honor the local location's enabled flag before uploading

ClusterConfiguration treats local and enabled independently, and ordinary writeFile/copyFile write only to getEnabledLocations. With local A disabled and B enabled, this path nevertheless uploads to A before consulting the enabled locations, then unconditionally includes A in written_locations. If A was disabled because it cannot accept writes, RESTORE fails there even though the enabled destination is healthy. Please honor the enabled-location set for the initial upload too, including choosing the matching callback client/namespace, or explicitly enforce and document a requirement that the local location remain enabled before starting any upload.

@clickhouse-gh clickhouse-gh Bot added the comp-object-storage-disks Object-storage disk layer: DiskObjectStorage, metadata storage adapters, transaction support for ... label Oct 23, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 3d0fadece with master 479496ca1 (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

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

Median compile-time ratio to the baselines is ×1.07 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +287.4 s (+8%) in total before that adjustment.

Job report

@Michicosun
Michicosun enabled auto-merge October 23, 2026 15:10
@Michicosun
Michicosun added this pull request to the merge queue Oct 23, 2026
Merged via the queue into master with commit db92fef Oct 23, 2026
178 checks passed
@Michicosun
Michicosun deleted the blob-writing-function-multi-location branch October 23, 2026 17:03
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 23, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 23, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 23, 2026
Backport #127568 to 26.8: Implement `writeFileUsingBlobWritingFunction` for Multi-Location Disks
clickhouse-gh Bot added a commit that referenced this pull request Oct 23, 2026
Backport #127568 to 26.10: Implement `writeFileUsingBlobWritingFunction` for Multi-Location Disks
clickhouse-gh Bot added a commit that referenced this pull request Oct 23, 2026
Backport #127568 to 26.9: Implement `writeFileUsingBlobWritingFunction` for Multi-Location Disks
@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 24, 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
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-improvement Pull request with some product improvements 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.4-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants