Repository navigation
Support tables with local and plain_rewritable disks in one storage policy - #1649
Conversation
…olicy ClickHouse rejects FREEZE for a table whose storage policy has a plain_rewritable disk, wherever its parts are, so create snapshots such a table without FREEZE: the active parts of the local disks are hardlinked into shadow the way FREEZE does and the parts of the plain disks are copied on the bucket level, with merges and moves of the table stopped (needs SYSTEM MERGES and SYSTEM MOVES grants), plain disks in skip_disks are skipped. Part paths from system.parts are matched against the raw system.disks.path and accessed through the disk_mapping-resolved disk path. Only local disks, and encrypted disks over them, are allowed next to plain disks: parts on an object disk with local metadata, including cache and encrypted wrappers, are rejected because only FREEZE maintains the hardlink counter which protects their blobs. sync_replicated_tables, freeze_by_part_where and ignore_not_exists_error_during_freeze apply as they apply to FREEZE. A part is skipped only when it is gone as a whole, a file missing inside a live part is an error. The shadow is removed best effort, a leftover is cleaned by cleanOwnFreezes at the end of create. <disk>/shadow is shared with clickhouse-server, which stats shadow/increment.txt on every FREEZE, so when clickhouse-backup runs as root the shadow root and shadow/<uuid> get the owner of the server data path, as the directories FREEZE creates have it, otherwise FREEZE of every table on the server fails with Permission denied afterwards.
64e2616 to
ba05fb6
Compare
Before 25.4 ClickHouse rejects every partition command except DROP, including ATTACH PART, for a table whose storage policy has a disk without hardlinks (plain/plain_rewritable), wherever its parts are (lifted by ClickHouse b2a1123c13e, first in v25.4.1, not backported to 25.3). Default restore of such a table on 24.8/25.3 failed with code 344 after the parts were already copied to detached. Fail early in restoreDataRegularByParts with a hint to restore_as_attach: ATTACH TABLE works there, verified on 24.8.14 and 25.3.14. TestPlainRewritableHybridS3 needs MOVE PARTITION to the plain volume, so it now requires 25.4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
CI failures in run 40681309512 (commit 64e2616) and a follow-up commit e20c634. 26.3 cascade (TestAzure, TestRBAC, TestKafkaKeeperOffsets, … all on env 24.8 / 25.3: I checked it with a standalone script (minio + clickhouse-server, policy hot=default / cold=s3_plain_rewritable, local parts only,
Known leftover: with |
Coverage Report for CI Build 40737963885Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage decreased (-2.5%) to 68.036%Details
Uncovered Changes
Coverage Regressions752 previously-covered lines in 22 files lost coverage.
Coverage Stats
💛 - Coveralls |
…-local-storage-policy # Conflicts: # ChangeLog.md
…-local-storage-policy # Conflicts: # ChangeLog.md
ClickHouse rejects
ALTER TABLE ... FREEZEfor a table whose storage policyhas a
plain_rewritabledisk, wherever its parts are(
checkAlterPartitionIsPossiblechecks every disk of the policy). Until nowcreatehandled only tables with all parts on plain disks and rejected thecommon hot/cold layout, a local hot volume with a
plain_rewritablecoldvolume, with "parts on both plain and non-plain disks".
What changes
createsnapshots such a table without FREEZE:SYSTEM SYNC REPLICAwhensync_replicated_tablesasks for it, thenSYSTEM STOP MERGESandSYSTEM STOP MOVESfor the table, started againonce the table is in the backup. A merge would replace the parts under the
snapshot, a TTL or manual move between the volumes would remove them, so
moves are now stopped for every table on a storage policy with plain disks,
not only for the mixed ones. The backup user needs the
SYSTEM MERGESandSYSTEM MOVESgrants.system.partsquery lists the active parts,--partitionsandfreeze_by_part_whereapply to it the way they apply toFREEZE PARTITION.<disk>/shadow/<uuid>/...,the layout FREEZE produces, so
MoveShadowToBackupand the rest of thepipeline work unchanged.
delete-on-destroy.txt,txn_version.txtandmetadata_version.txtare left out as FREEZE leaves them out. Part pathsare matched against the raw
system.disks.pathand accessed through thedisk_mapping-resolved disk path, so a sidecar withdisk_mappingworks.a plain disk in
skip_disksis skipped.UNFREEZEis rejected for such a table as FREEZE is, so the shadow isremoved directly, best effort, a leftover is cleaned by
cleanOwnFreezesat the end of
create.ignore_not_exists_error_during_freezeapplies: a table dropped betweenthe listing and the snapshot gives an empty backup of it instead of a
failed
create. A part is skipped only when it is gone as a whole(
DROP PARTITION), a file missing inside a live part is an error.Limitations
Only local disks, and
encrypteddisks over them, are supported next toplain disks. Parts on an object disk with local metadata (
s3,azure,their
cacheandencryptedwrappers,web,hdfs) are rejected with anerror naming the disk and its type: their blobs are protected by the
hardlink counter inside the metadata files, which only FREEZE maintains.
A
cachewrapper over an object disk is listed byGetDisksunder theunderlying disk name while
system.partsreports the cache name, the errormessage points at this case instead of a missing disk.
restoreof the plain disk parts still needs ClickHouse 25.11+(
SYSTEM DROP DISK METADATA CACHE),createworks from 24.8.Tests
TestPartPathOnDiskandTestFilterPlainPolicyParts(unit) cover thedisk_mappingpath matching and the disk type guard.TestHardlinkPart(unit) covers the FREEZE-like snapshot of a part withprojections and excluded files,
HardlinkPartno longer chowns thetemporary shadow directories so the test runs as root too.
TestPlainRewritableHybridS3(integration,s3_plain_rewritable_hybridpolicy added to
dynamic_settings.sh) runscreate_remotewith andwithout the plain disk in
skip_diskson every version from 24.8, checksthat merges and moves work again afterwards and that the backup metadata
lists the parts of both disks, and verifies the restored row counts on
25.11+.