8000 Reuse parts moved between local disks in --diff-from-remote, fix #1663 by Slach · Pull Request #1667 · Altinity/clickhouse-backup · GitHub
[go: up one dir, main page]

Skip to content

Reuse parts moved between local disks in --diff-from-remote, fix #1663 - #1667

Merged
Slach merged 3 commits into
masterfrom
issue_1663_cross_disk_reuse
Nov 6, 2026
Merged

Slach merged 3 commits into
masterfrom
issue_1663_cross_disk_reuse

Conversation

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

Fixes #1663

A part moved by TTL ... TO VOLUME / ALTER TABLE ... MOVE PARTITION ... TO DISK keeps its name and hash_of_all_files, but create --diff-from-remote / upload --diff-from-remote looked it up only on the same disk of the diff backup, so every moved part was uploaded again.

Changes

  • markDuplicatedParts (upload) and diffTableMetadataForDisk (create) look a part up on all disks of the diff backup; the add check checksums during upload --diff-from / --diff-from-remote if data part name the same #1307 hash_of_all_files / checksums check is unchanged.
  • Cross-disk reuse is allowed only between plain local disks. Object disks keep object metadata files and encrypted disks keep ciphertext in the backup, while hash_of_all_files is the same, so reusing across disk types would corrupt restored data.
  • ClickHouse 22.9+ reports type=Local for an encrypted disk over a local one, GetDisks now reads system.disks.is_encrypted (Disk.IsEncrypted).
  • findDiffBackupFilesRemote (download) skips other-disk candidates when only one of the disks is plain local (isCrossDiskDownloadIncompatible); a required disk absent in system.disks is described by disk_types of the required backup, unknown type is not filtered.
  • findRequiredPartLocal (restore) does not hardlink a required part stored on another disk, it is downloaded from remote.
  • --diff-from (local) keeps same-disk only matching, its inode comparison never matches across disks.

Tests

  • unit: TestMarkDuplicatedPartsMovedBetweenDisks (fails on master), TestIsCrossDiskDownloadIncompatible
  • integration: TestDiffFromRemoteMovedParts with new mixed_disk_types policy (default, hdd1, disk_s3, hdd3_encrypted), moves partitions to each disk, checks required flags and data after local restore and restore_remote; passed locally on 26.8 and 22.8.

🤖 Generated with Claude Code

A part moved by TTL TO VOLUME or MOVE PARTITION keeps its name and
hash_of_all_files, but create/upload looked it up only on the same disk
of the diff backup, so every moved part was uploaded again.

Look the part up on all disks of the diff backup, but reuse it only when
both disks are plain local disks: object disks keep object metadata and
encrypted disks keep ciphertext in the backup while hash_of_all_files is
the same. 22.9+ reports type=Local for encrypted disks, so read
system.disks.is_encrypted. The same plain-local filter now guards the
cross-disk lookup in download, and restore of a local increment does not
hardlink a required part from another disk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Slach Slach added this to the 2.8.4 milestone Nov 6, 2026
Slach and others added 2 commits November 6, 2026 11:05
replaceStorageDiskNameForReBalance renames disk_s3 only inside the s3
config files, a policy in a separate file kept referencing disk_s3 and
clickhouse-server failed to start with UNKNOWN_DISK in TestS3 and
TestAlibabaOverS3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drwetter/testssl.sh moved to testssl/testssl.sh and the old URL no longer
redirects for git, clone fails with "Remote branch v3.2rc3 not found" in
every CI job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 42190604160

Coverage increased (+0.07%) to 70.67%

Details

  • Coverage increased (+0.07%) from the base build.
  • Patch coverage: 5 uncovered changes across 2 files (68 of 73 lines covered, 93.15%).
  • 26 coverage regressions across 5 files.

Uncovered Changes

File Changed Covered %
pkg/backup/upload.go 35 32 91.43%
pkg/backup/download.go 15 13 86.67%
Total (5 files) 73 68 93.15%

Coverage Regressions

26 previously-covered lines in 5 files lost coverage.

File Lines Losing Coverage Coverage
pkg/storage/gcs.go 11 56.05%
pkg/storage/general.go 10 69.4%
pkg/storage/sftp.go 2 59.17%
pkg/storage/structs.go 2 81.82%
pkg/status/status.go 1 90.91%

Coverage Stats

Coverage Status
Relevant Lines: 29867
Covered Lines: 21107
Line Coverage: 70.67%
Coverage Strength: 34421.33 hits per line

💛 - Coveralls

@Slach
Slach merged commit 36fc213 into master Nov 6, 2026
30 checks passed
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.

Incremental backup re-uploads every part that moved between disks (diff-from-remote keys part reuse on the current disk)

2 participants

0