Repository navigation
Fix restoring a lightweight snapshot from Azure when the source disk has a key prefix - #122697
Conversation
…has a key prefix The snapshot manifest records the source disk's object namespace, which for Azure is `<container>/<prefix>` when the disk endpoint has a path below the container (`AzureObjectStorage::getObjectsNamespace`), while S3 records only the bucket. The Azure `snapshot_reader_creator` used that namespace verbatim as a container name, so the reader's container-level existence check went to `.../<container>/<prefix>/?restype=container` and Azure rejected it with `400 InvalidUri`. Split the namespace into `container_name` and `endpoint.prefix`, mark the container as existing, and keep a connection-string account URL as is. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Workflow [PR], commit [7505357] Summary: ✅
AI ReviewSummaryThis PR moves Azure lightweight-snapshot restores onto Findings❌ Blockers
Final Verdict
LLVM Coverage ReportMeasured on commit 7505357.
Changed lines: Changed C/C++ lines covered: 6/6 (100.00%) · Uncovered code |
Move the namespace split out of the Azure backup engine's snapshot reader creator into `makeSnapshotSourceConnectionParams` in `BackupIO_AzureBlobStorage`, and cover it with a gtest: a prefixed namespace is split into container and prefix, a plain container namespace is unchanged, the backup's own connection params are not mutated, and a connection-string account URL is kept. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 16 s compile time in total, 8 of them have a recent master baseline. |
With connection-string auth `createForContainer` builds the client from the connection string and ignores `storage_account_url`, so the recorded `original_endpoint` cannot be applied; leaving it unused would silently read the backup's account instead of the snapshot's. Compare the recorded endpoint with the connection string's blob endpoint (SDK-canonical, trailing slashes ignored) and throw `BAD_ARGUMENTS` when they name different accounts. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Review: the lightweight-snapshot code path it covers is used only in Cloud, so the test stays in the Cloud repo (sync PR) instead. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
…ction string Review: the same account is reachable through several hosts (a private link alias, Azurite by IP or by host name), so comparing the manifest endpoint with the connection string's blob endpoint as URLs rejected valid restores. Compare the account names instead: the connection string's AccountName (or the account its blob endpoint names) against the account the manifest endpoint names, the first host label for `<account>.blob.<suffix>` and `<account>.privatelink.blob.<suffix>` hosts or the first path segment of a path-style endpoint. A URL that does not reveal its account, such as a custom domain, is let through and a wrong account fails at the first read. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…pshot endpoints that reveal none storageAccountOfURL took any non-empty path as a path-style account name, so a host-style endpoint that carries a path, e.g. https://acct.blob.core.windows.net/container/data/, named `container` rather than `acct`, and a restore from the backup's own account was rejected as a cross-account one. The host is now consulted first (`<account>.blob|dfs.<suffix>` and the privatelink aliases), and the first path segment is only taken as the account when the host names none, which is how Azurite endpoints look. With connection-string auth an endpoint that does not reveal its account (a custom domain) was let through on the assumption that a wrong account fails at the first read. It does not: the container is marked as existing, so nothing probes the source, and another account with the same container and key layout would be restored from silently. Such an endpoint is now rejected with BAD_ARGUMENTS as well. Co-Authored-By: Claude Fable 5.1 <[email protected]>
The worker arm's `INSERT INTO t05288_dst ... SETTINGS ast_fuzzer_runs = 5` makes the server run fuzzed copies of it, and the copies write into `t05288_dst` too. In the failing run one copy became `... NATURAL INNER JOIN numbers(1048577)`, a cross join, and wrote 161 million rows with `id < 2000` in the 10 seconds a fuzzed query may run. The `source_rows_written` check then scanned `t05288_dst WHERE id < 2000` and failed under the CI profile's `max_rows_to_read = 20000000` with `Code: 158 ... Limit for rows (controlled by 'max_rows_to_read' setting) exceeded, max rows: 20.00 million, current rows: 48.80 million (TOO_MANY_ROWS)`. Read the statement's own `QueryFinish` row in `system.query_log` instead and assert that its `written_rows` equals the source row count. Fuzzed copies run as separate internal queries (`is_internal = 1`) that never log `QueryFinish`, so what they write no longer affects the check. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122697&sha=aa88a04fe7cd944d2f7401c635b3a45e8b576bac&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29 Failed on: ClickHouse#122697 Related: ClickHouse#115786 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review: a `storage_account_url` is recorded verbatim and may be a proxy whose path prefix is not an account, so the first path segment of an arbitrary URL proves nothing. Take it only when the host is an IPv4 address or a bare name (Azurite, localhost); any other host that is not an Azure one reveals no account and the connection-string check rejects it as unverifiable, instead of reporting a mismatch against a made-up account. An emulator reached through a dotted host name is rejected the same way; by IP or by a bare name it still compares by account. Co-Authored-By: Claude Fable 5.1 <[email protected]>
The connection-string branch tried to prove that the connection string's own endpoint is equivalent to the recorded one (URL equality, then account names, then host and path rules), and every rule had a shape it got wrong: host aliases, hosts that reveal no account, proxy path prefixes, service paths that CreateFromConnectionString() drops. Stop proving equivalence instead: CreateFromConnectionString() takes the endpoint from the connection string alone, so point the connection string at the recorded endpoint by replacing its BlobEndpoint and let the key or SAS it carries authorise the reads there, or fail with Azure's refusal if it belongs to another account. That is what every other auth method and the S3 reader already do through storage_account_url. The recorded endpoint is reduced to a service URL first: query parameters (a SAS of the source disk) are dropped, and an endpoint recorded as a connection string (a source disk configured with one) is reduced to its blob endpoint. Co-Authored-By: Claude Fable 5.1 <[email protected]>
| AzureBlobStorage::ConnectionParams makeSnapshotSourceConnectionParams( | ||
| const AzureBlobStorage::ConnectionParams & backup_connection_params, const String & endpoint, const String & blob_namespace) | ||
| { | ||
| auto connection_params = backup_connection_params; |
There was a problem hiding this comment.
Because this starts from backup_connection_params, it also inherits the backup location's endpoint.add_account_name_to_url flag. That breaks a supported mixed-shape restore: if the backup is opened through a path-style endpoint (so this flag is true) but the snapshot was taken from a host-style source like https://acct.blob.core.windows.net, line 128 swaps in the host-style service_url and createForContainer() still appends /acct from the backup params. The source client then targets https://acct.blob.core.windows.net/acct/<container> instead of https://acct.blob.core.windows.net/<container>, so a same-account restore still fails.
Please rebuild the endpoint shape from service_url here — at minimum reset add_account_name_to_url after repointing the endpoint, and cover the path-style-backup / host-style-source combination with a regression test.
| { | ||
|
|
||
| #if CLICKHOUSE_CLOUD | ||
| /// Connection params for reading the objects a lightweight snapshot references, built from the endpoint |
There was a problem hiding this comment.
Could we make the comment a bit shorter?
Cherry pick #122697 to 26.9: Fix restoring a lightweight snapshot from Azure when the source disk has a key prefix
…zure when the source disk has a key prefix
Backport #122697 to 26.8: Fix restoring a lightweight snapshot from Azure when the source disk has a key prefix
Backport #122697 to 26.7: Fix restoring a lightweight snapshot from Azure when the source disk has a key prefix
Backport #122697 to 26.9: Fix restoring a lightweight snapshot from Azure when the source disk has a key prefix
…hot from Azure when the source disk has a key prefix
…hot from Azure when the source disk has a key prefix
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix container existence check during
RESTOREof a lightweight snapshot from Azure Blob Storage by parsing the saved namespace into container name and prefix.Why
A lightweight snapshot manifest records the source disk's endpoint and object namespace, and for an Azure disk whose endpoint has a path below the container e.g.
https://<account>.blob.core.windows.net/<container>/data/) that namespace is<container>/data/. OnRESTOREthe Azure snapshot reader used the recorded namespace verbatim as the container name, so its container-existence check checkedhttps://<account>.blob.core.windows.net/<container>/data/. Azure rejects a container-level request on a URL with extra path segments with400 InvalidUri, so every such restore failed before reading a single blob.What
The Azure snapshot reader creator now delegates to
makeSnapshotSourceConnectionParams(BackupIO_AzureBlobStorage), which splits the recorded namespace at the first/into the container name and a blob prefix, so blob reads and native copies resolve to<container>/<prefix>/<key>and a namespace without a/behaves exactly as before. It marks the container as existing, since the snapshot was taken from it and the existence check was the failing request, and it works on a copy of the backup's connection params instead of mutating them. With connection-string auth the recorded endpoint cannot be applied, so the helper compares it with the connection string's blob endpoint and throwsBAD_ARGUMENTSwhen they name different accounts instead of silently reading from the backup's account, and because the split happens on the read side it also repairs restores of snapshots taken before this fix.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/122697]
Version info
26.10.1.1680-master(included in26.10and later)26.9.13.4,26.8.20.5,26.7.24.5