Repository navigation
Disallow zip backup format for S3 and Azure Blob Storage - #101770
Conversation
Zip format requires seeking to read the central directory at the end of the archive, which causes severe performance problems with object storage (each seek results in a new HTTP request). Reject zip/zipx extensions early with a clear error message suggesting tar-based formats. Fixes ClickHouse#53483
Cover the new early rejection of `BACKUP ... TO S3(...)` and `BACKUP ... TO AzureBlobStorage(...)` when the destination uses a `.zip` extension. Zip requires seeking, which turns every read into a separate HTTP request on object storage, so it is rejected with a clear error suggesting tar-based formats. Related: ClickHouse#53483 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [aabc354] Summary: ✅
AI ReviewSummaryThis PR rejects Findings❌ Blockers
Final VerdictDo not merge as is. The direct guard itself is straightforward, but the restore compatibility break needs an explicit product decision in code, and the broadened contract still needs Azure/ |
The earlier change only rejected zip archives for the direct `S3(...)` and `AzureBlobStorage(...)` backup engines. A `Disk(...)` destination can also be backed by object storage (for example an `s3`-typed disk), and in that case a zip archive hits the exact same seek-heavy read path through `BackupReaderDisk`: zip requires seeking to read its central directory, and every seek over object storage turns into a separate HTTP request (issue ClickHouse#53483). Reject `.zip`/`.zipx` in `registerBackupEnginesFileAndDisk` as well when the disk's `getDataSourceDescription().object_storage_type` is `S3` or `Azure`, so the slow path is not reachable through the `Disk` backup engine. Local-disk `Disk(...)` and `File(...)` zip backups remain allowed. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Remove the old `test_backup_to_zip`, which backed up to `S3('....zip', ...)` and
expected success; that expectation now contradicts the rejection introduced by
this PR and made the suite assert both old and new behavior (the test failed in
CI). The new behavior is already covered by `test_backup_to_s3_zip_not_supported`.
Add `test_backup_to_object_storage_disk_zip_not_supported`, which backs up to
`Disk('disk_s3', '....zip')` (an `s3`-typed disk) and asserts the new
`BAD_ARGUMENTS` rejection, covering the object-storage-backed `Disk` path.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…-backup # Conflicts: # tests/integration/test_backup_restore_s3/test.py
`disk_s3_plain_rewritable_03517` is an `object_storage`/`s3` disk, so backing up a `.zip` archive to it is now rejected (zip requires seeking, which is slow over object storage). Switch the test to a `.tar` archive: it triggers the same empty `root_path` (the archive's `parent_path`) that the test guards against during plain_rewritable cleanup, so the stack-overflow regression coverage is preserved. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Pushed Blocker 1 — contradictory S3 zip test (the red CI): removed the old Blocker 2 — object-storage Master tests adapted to the new behavior (they backed up/restored zip on object storage and would otherwise fail):
Also merged Note: the existing approval predates this scope expansion (the |
| BackupImpl::ArchiveParams archive_params; | ||
| if (hasRegisteredArchiveFileExtension(s3_uri)) | ||
| { | ||
| if (hasSupportedZipExtension(s3_uri)) |
There was a problem hiding this comment.
This also rejects RESTORE ... FROM S3('...zip') for archives that already exist, because the check runs before the open_mode branch. That makes old object-storage .zip backups unrestorable immediately after upgrade unless the operator manually copies them to local storage, and there is no compatibility/override setting for a disaster-recovery restore. Please either keep the rejection to writes/new backups, or add an explicit opt-in compatibility setting for READ/UNLOCK paths and document that migration path.
There was a problem hiding this comment.
Rejecting RESTORE ... FROM S3('...zip') for pre-existing archives is intentional, not an oversight — it is the slow path reported in #53483 (reading the zip central directory seeks, and every seek is a separate HTTP request, which makes such a RESTORE effectively unusable, not merely slow). That is why this is categorized as a Backward Incompatible Change.
The data is not stranded: a supported migration path remains for the rare operator whose only copy is a .zip on object storage — copy the archive to local storage and restore from there, since local File('...zip') and local-disk Disk('...zip') zip backups stay allowed. The hard rejection only removes the direct object-storage seek path.
I've added a focused RESTORE test (test_restore_from_s3_zip_not_supported in 52ec036aac0) that locks this contract: a non-existent .zip object is enough to prove the rejection fires up front, by file extension, before the archive is ever opened.
Whether to additionally offer an explicit opt-in compatibility setting that re-enables the seek-heavy READ/UNLOCK path is a product decision for the maintainers — it would reopen exactly the path this PR closes, so I've left it out rather than add it speculatively.
Address AI review: the existing tests covered only BACKUP rejection. The seek-heavy path reported in issue ClickHouse#53483 is also hit on RESTORE, and the zip check in `registerBackupEngineS3` fires by file extension before the `open_mode` branch, so `RESTORE ... FROM S3('...zip')` is rejected up front too. This test locks that contract: a non-existent `.zip` object is enough to prove the archive is never opened. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Pushed What changed since the last CI run:
On the AI ❌ Block (RESTORE of pre-existing object-storage CI: the only red on the previous run was Note: the existing approval predates the scope expansion (object-storage |
|
Re-checked CI completed since the last comment:
Only reds:
|
|
CI on Final tally: 148 passed / 20 skipped / 2 failed. The only two reds are Nothing to change on my side: the C++ in all three backup engines is correct, test coverage is comprehensive (S3/Azure The PR is effectively ready to merge, pending your re-review of the broadened scope (object-storage |
|
Re-ran the two red These were the only reds, and both failed with Everything else is green (148 passed / 20 skipped), including all builds, Fast test, the full integration suite ( The only remaining step before merge is a re-review of the broadened scope (object-storage |
|
The re-run of the two stress jobs on
I re-verified the diff end-to-end: the zip rejection in all three engines ( The only remaining step before merge is your re-review of the broadened scope (object-storage |
|
Refreshed the branch by merging the latest |
|
Merged |
| azure_query(node, "DROP TABLE test_restored") | ||
|
|
||
|
|
||
| def test_backup_zip_not_supported(cluster): |
There was a problem hiding this comment.
The PR description now promises the same early rejection for RESTORE ... FROM AzureBlobStorage('...zip'), not just BACKUP, but this suite only exercises the write path. The S3 path already has a dedicated RESTORE regression because the important invariant is that the zip guard fires before the open_mode branch and before any blob is opened. Please add the analogous Azure negative test (a non-existent .zip blob is enough) so that moving this check below the READ/UNLOCK branch will fail CI.
| assert "Zip archive format is not supported for S3 backups" in error, error | ||
|
|
||
|
|
||
| def test_backup_to_object_storage_disk_zip_not_supported(cluster): |
There was a problem hiding this comment.
This covers the object-storage Disk(...) write path, but the PR body also claims RESTORE is rejected for Disk(...) destinations backed by object storage. That contract is still untested: unlike test_restore_from_s3_zip_not_supported, nothing fails if a future refactor leaves the guard only on the writer side. Please add a negative RESTORE TABLE ... FROM Disk('disk_s3', '...zip') case (using a non-existent archive is enough) to lock the READ path too.
| BackupImpl::ArchiveParams archive_params; | ||
| if (hasRegisteredArchiveFileExtension(s3_uri)) | ||
| { | ||
| if (hasSupportedZipExtension(s3_uri)) |
There was a problem hiding this comment.
This is a user-visible behavior change, and the repo still has English docs that instruct people to do exactly what now throws BAD_ARGUMENTS: docs/products/cloud/guides/migration/oss-to-cloud-backup-restore.mdx:419 uses S3('...backup.zip'), and docs/integrations/connectors/data-ingestion/AWS/integrating-s3-with-clickhouse.mdx:1291-1301 uses Disk('s3_express', 't.zip') for both BACKUP and RESTORE. Please update those examples to a tar-based format and document the migration path for existing object-storage .zip backups.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 15/28 (53.57%) · Uncovered code |
|
@Onyx2406 what about other compression formats? Should they be disallowed as well? |
…3-backup Disallow zip backup format for S3 and Azure Blob Storage
What this PR does
Zip archives require seeking to read their central directory, which is very slow over object storage where each seek turns into a separate HTTP request (see #53483 — a slow
RESTOREof a many-column table from S3). This PR rejects thezip/zipxbackup archive format early, with a clear error message suggesting tar-based formats, whenever the backup is stored on object storage:S3(...)andAzureBlobStorage(...)backup destinations, andDisk(...)destinations whose disk is backed by object storage (object_storage_typeisS3orAzure, e.g. ans3/s3_plain_rewritabledisk).The check applies to both
BACKUPandRESTORE, because the seek-heavy path is hit when reading an existing zip archive too (the case reported in #53483). LocalFile(...)and local-diskDisk(...)zip backups remain allowed.Closes: #53483
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Reject the
zip/zipxbackup archive format for backups stored on object storage — directS3(...)/AzureBlobStorage(...)destinations andDisk(...)destinations backed by S3 or Azure — for bothBACKUPandRESTORE. Zip requires seeking to read its central directory, which is very slow over object storage. Use a tar-based format such astar.gzinstead.