8000 embedded URL restore: update .backup manifest after .sql rewrite by Slach · Pull Request #1669 · Altinity/clickhouse-backup · GitHub
[go: up one dir, main page]

Skip to content

embedded URL restore: update .backup manifest after .sql rewrite - #1669

Open
Slach wants to merge 1 commit into
masterfrom
embedded_url_manifest_1668
Open

Slach wants to merge 1 commit into
masterfrom
embedded_url_manifest_1668

Conversation

@Slach
@Slach Slach commented Nov 6, 2026
Copy link
Copy Markdown
Collaborator

Fixes #1668

Problem

fixEmbeddedMetadataRemote rewrites metadata/**/*.sql objects in place for embedded backups without embedded_backup_disk (BACKUP TO S3/GCS/Azure(url)). It doesn't update the .backup manifest. ClickHouse 26.9.x and 26.10.1 compare the object size with the manifest before reading and fail with code: 1009 S3_OBJECT_CHANGED_DURING_READ. ClickHouse reverted that check in 26.10.2+ (ClickHouse/ClickHouse@62eb34814e2), but the manifest still gets out of sync.

Changes

  • pkg/backup/embedded_manifest.go: after the rewrite, the node that executes RESTORE recalculates size and checksum of every .sql listed in .backup and uploads the manifest back. The checksum is CityHash128 v1.0.2 chained over 2048-byte blocks, the same way HashingReadBuffer computes it. ON CLUSTER workers don't touch the shared manifest, so concurrent writes can't overwrite each other.
  • fixEmbeddedMetadataSQLQuery: {database}/{table} were taken from the wrong path components (metadata/<db> instead of <db>/<table>). Every ReplicatedMergeTree() table of a database got the same replica path, and restore failed with code: 253 Replica ... already exists.
  • Test infra: 26.10 refuses to start with unknown disk elements (code 137). dynamic_settings.sh drops cache_enabled/send_metadata for 26.10+.

Tests

  • Unit tests: checksums match a .backup written by ClickHouse 26.10, including a file larger than 2048 bytes. Manifest rewrite covers data_file, use_base and empty files.
  • New integration test TestEmbeddedS3URLRewrittenMetadata: ENGINE=Replicated database, ReplicatedMergeTree() without arguments, MV, create_remote / restore_remote --rm over S3 URL.
    • 26.9 without the fix: fails with code 1009, same as the reported log.
    • 26.9 with the fix: passes.
    • 26.8 with the fix: passes, and TestEmbeddedS3Cleanup passes too.
  • Not run locally: the full TestEmbedded* suite on 26.8/26.10. 26.9/26.10 are not in the CI matrix yet.

🤖 Generated with Claude Code

fixEmbeddedMetadataRemote rewrites metadata/**/*.sql objects in the bucket
in place but left the .backup manifest untouched. ClickHouse 26.9.x and
26.10.1 check the object size against the manifest before reading and fail
with code 1009 S3_OBJECT_CHANGED_DURING_READ.

After the rewrite the node which executes RESTORE recalculates size and
checksum (CityHash128 over 2048 bytes blocks, as HashingReadBuffer does)
of every .sql listed in .backup and uploads the manifest back. ON CLUSTER
workers don't touch the shared manifest to avoid lost updates.

Also fix {database}/{table} substitution in fixEmbeddedMetadataSQLQuery:
they were taken from the wrong path components (metadata/<db> instead of
<db>/<table>), so every ReplicatedMergeTree() table of a database got the
same replica path and restore failed with code 253.

Test infra: 26.10 refuses unknown disk elements (code 137), drop
cache_enabled/send_metadata for 26.10+.

Fixes #1668
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

embedded URL restore fails on ClickHouse 26.9+: code 1009 S3_OBJECT_CHANGED_DURING_READ after .sql metadata rewrite

1 participant

0