Repository navigation
Add factory-owned backup destination identity - #110610
Conversation
Add `BackupFactory::getDestinationIdentity` and register engine-specific identity callbacks alongside backup creators. Share effective destination resolution for `S3`, `AzureBlobStorage`, `File`, and `Disk`, while rejecting non-persistent engines. Freeze named collections in `BackupInfo` so identity generation and later backup creation observe the same resolved collection. Encode identities with a versioned, length-prefixed envelope and exclude credentials.
|
Workflow [PR], commit [91ed1b4] Summary: ✅
AI ReviewSummaryThis PR adds factory-owned backup destination identities and freezes named collections so identity generation and backup creation can share the same resolved backup location. The overall design is reasonable, but the Azure Findings
Final VerdictChanges requested. |
There was a problem hiding this comment.
Pull request overview
This PR introduces a factory-owned, versioned backup destination identity API (BackupFactory::getDestinationIdentity) with per-engine identity callbacks, intended to provide a deterministic, credential-free identity for effective backup destinations (including named-collection resolution via BackupInfo::freezeNamedCollection).
Changes:
- Added
BackupFactory::getDestinationIdentityand extended engine registration to include an engine-specific destination-identity callback. - Refactored
File/Disk,S3, andAzureBlobStorageengines to share destination-resolution logic between backup creation and identity generation;Memory/Nullexplicitly reject persistent identity. - Added unit tests covering identity canonicalization, credential exclusion, and named-collection freezing behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Backups/tests/gtest_backup_info.cpp | Adds tests for destination identity behavior, redaction, and named-collection freezing. |
| src/Backups/registerBackupEnginesFileAndDisk.cpp | Centralizes local destination resolution and adds identity components for File/Disk. |
| src/Backups/registerBackupEngineS3.cpp | Centralizes S3 destination resolution and adds S3 identity generation. |
| src/Backups/registerBackupEngineAzureBlobStorage.cpp | Centralizes Azure destination resolution, adds identity generation, and validates certain endpoint forms. |
| src/Backups/BackupIO_Null.cpp | Registers Null identity callback that rejects persistent identity. |
| src/Backups/BackupIO_Memory.cpp | Registers Memory identity callback that rejects persistent identity. |
| src/Backups/BackupInfo.h | Adds frozen_named_collection and declares freezeNamedCollection. |
| src/Backups/BackupInfo.cpp | Implements freezeNamedCollection and uses the frozen snapshot in getNamedCollection. |
| src/Backups/BackupFactory.h | Adds destination identity API and extends engine registration to include identity callbacks. |
| src/Backups/BackupFactory.cpp | Implements identity envelope formatting and stores engines as {creator, identity_fn}. |
jkartseva
left a comment
There was a problem hiding this comment.
Overall, I like the factory-based approach
|
|
||
| /// Stores a private copy of the resolved named collection so later identity generation | ||
| /// and backup creation use the same collection state. | ||
| BackupInfo freezeNamedCollection(ContextPtr context) const; |
There was a problem hiding this comment.
Maybe call it pinNamedCollection / pinned_named_collection instead of frozen? I think it has better semantics.
There was a problem hiding this comment.
I preferred freeze here because we resolve the collection and overrides into a detached snapshot. The original collection can still change or be dropped, so pin could imply a lifetime or lease guarantee that we do not provide. What remains stable is the copied snapshot, which I think makes freezeNamedCollection / frozen_named_collection more precise.
This is not the hill I'll die on, though. We can change the name if you still think it makes more sense
| /// Returns a versioned, credential-free identity of the effective backup location. | ||
| /// Named collections must be frozen first so identity generation and backup creation | ||
| /// observe the same collection state. | ||
| String getDestinationIdentity(const BackupInfo & backup_info, ContextPtr context) const; |
There was a problem hiding this comment.
Now that getDestinationIdentity exists,BackupInfo::withoutS3Credentials looks out of place – and tracing it back, it was out of place to begin with: BackupInfo is meant to be engine-agnostic, yet this method is wired specifically for S3 (my fault as a reviewer).
Worth folding the credential classification into the per-engine path so redaction stops being S3-only. Just not in this PR though.
There was a problem hiding this comment.
Agreed that credential redaction ultimately belongs in engine-owned code. It is not a mechanical move, though: the current S3 path includes AST evaluation and URL redaction, while an engine-neutral callback also needs correct AzureBlobStorage connection-string, SAS, and account-key handling plus security-focused tests. I will keep that as a separate follow-up so this PR remains focused.
The plan after merging this PR:
- Add an engine-owned credential-redaction callback in a dedicated PR.
- Move S3 redaction out of BackupInfo and add proper Azure redaction and security-focused tests.
| /// Returns a versioned, credential-free identity of the effective backup location. | ||
| /// Named collections must be frozen first so identity generation and backup creation | ||
| /// observe the same collection state. | ||
| String getDestinationIdentity(const BackupInfo & backup_info, ContextPtr context) const; |
There was a problem hiding this comment.
Do you think this factory method have potential to evolve beyond the backup-from-snapshot use case? E.g., I would think of base -> incremental backup chain matching. Not in this PR.
There was a problem hiding this comment.
Yep, definitely. This is why it's in BackupFactory and delegates the resolution to each engine. The base/incremental chain handling is a plausible use case. e.g. it oculd help compare base-backup destinations, validate retries or derive stable coordination keys without persisting credentials.
Document why `S3` destination identities can remove all valid trailing slashes while `AzureBlobStorage` removes only the slash consumed by path joining.
Use `fmt::format_to` to append framed identity components without a temporary string. Rename the registered callback field to `destination_identity` for consistency with `creator`.
Distinguish the three-argument connection string or URL form from the five-argument `AzureBlobStorage` form, which requires a plain storage account URL.
Drop the resolved named collection snapshot when `withoutS3Credentials` rewrites an `S3` locator. The snapshot contains the original overrides and must not remain available behind a redacted locator.
Resolve semantic conflicts with the new ZIP guards in `master` that caused the merge queue's `Fast test` and `Build (amd_binary)` jobs to fail. Use the resolved archive fields for `S3`, `AzureBlobStorage`, and object-storage-backed `Disk` destinations.
Azure Core does not support URL userinfo, while destination identity previously stripped it and accepted the remaining endpoint. Reject it instead and verify credential-bearing URLs fail without exposing the secret.
|
@groeneai investigate the job that is failing: https://github.com/ClickHouse/ClickHouse/actions/runs/29936566085/job/88994375081 There's an already created issue: #111477 |
|
@pamarcos That job is the chronic plain-rewritable
Re #111477: it was filed after the merge, but the runs it cites are all on branches predating #111353, i.e. the same pre-fix artifact. No second signature is failing on master, and it tracks the same race as #111289. (Release branch 26.7 still shows it and would need a backport of #111353.) No separate fix is needed here. |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 431/487 (88.50%) · Uncovered code |
…on-identity-v2 Add factory-owned backup destination identity
Adds
BackupFactory::getDestinationIdentity, with engine-specific identity callbacksregistered alongside backup creators.
S3,AzureBlobStorage,File, andDisksharetheir effective destination resolution between creation and identity generation, while
MemoryandNullreject persistent identity.The identity has a versioned, length-prefixed envelope and excludes authentication data.
BackupInfo::freezeNamedCollectionretains the resolved collection snapshot so identitygeneration and later backup creation observe the same destination.
This replaces the duplicated backup-engine parser from the earlier attempt with a smaller
factory-owned design. It remains infrastructure-only and has no production callers yet.
Related: #109083
Validated by building
src/unit_tests_dbms, running all focusedBackupInfotests 60 times,and running both repository style checks.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not for changelog.
Documentation entry:
Version info
26.7.1.1377(included in26.7and later)