Repository navigation
Conversation
A cache disk shares system.disks.path with the disk it wraps, so GetDisks lists the pair once, under the wrapped disk name. For a part behind the cache system.parts.disk_name is the wrapped disk on ClickHouse 25.8 and the cache disk on 26.8, system.storage_policies changed the same way. On 26.8 create failed for every table with a plain_rewritable disk behind a cache disk in its storage policy, even with the disk in skip_disks: `db`.`t` have parts on plain disks and on disk <cache disk> which is not a local disk of system.disks GetDisks now keeps the names of the cache wrappers collapsed into a disk in Disk.Aliases and a disk is found by any of its names. The disk keeps the wrapped disk name, so backup metadata, shadow/<db>/<table>/<disk>_* archives and object_disk_path/<backup>/<disk>/ prefixes don't change and an increment made on 26.8 reuses the parts of a backup made on 25.8. - the parts of a table backed up without FREEZE are attributed to the GetDisks entry, whichever name system.parts reports - skip_disks skips a cache disk and the disk it wraps by either name - rebalance, the dry-run estimate of create and the hardlink of existing parts in download match system.parts.disk_name the same way The FREEZE path doesn't use system.parts.disk_name and was not affected: an object disk with local metadata behind a cache disk is backed up on 26.8 by 2.8.3 as well. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
create/create_remotefails on ClickHouse 26.8 for every table whose storage policy has a volume on acachedisk which wraps a
plain_rewritabledisk. The same clickhouse-backup 2.8.3 with the same config works on 25.8.One such table fails the backup of the whole server, and
skip_disksdoesn't help: the error is raised before thedisk is skipped.
Cause
ClickHouse changed the disk name it reports for a part behind a cache disk. Same data volume, same storage
configuration, a volume declared on
plain_cache(type = cache,disk = plain):system.parts.disk_namesystem.storage_policies.disksplain(the wrapped disk)['plain']plain(the wrapped disk)['plain']plain_cache(the cache disk)['plain_cache']plain_cache(the cache disk)['plain_cache']system.diskslists both names with the samepathon both versions,cache_pathis non-empty only for thecache disk.
The change is ClickHouse#96444 "Use cache layer as disk
name", merged into 26.2.1.521 and labelled
pr-not-for-changelog, so it is not in the changelog.ClickHouse#98665 describes the same change from the
TTL ... TO DISKside ("there was a bug in the previous version where the name of the cache disk was copied fromthe wrapped disk") and names ClickHouse#96070, which is in 26.2 as well.
clickhouse-backup is not ready for the new name:
getDisksFromSystemDisksgroupssystem.disksbyd.pathand takesargMin(d.name, d.cache_path != ''), sothe cache disk and the wrapped disk are one
Disknamed as the wrapped disk. The comment there sayssystem.partsalways reports the wrapped disk name.filterPlainPolicyPartsandlinkLocalPartsToShadowlook the disk of a part up withfindDiskByName(diskList, part.DiskName), getnilfor the cache disk name and return the error above.How to reproduce
ClickHouse 26.2+. The error was reproduced on 26.8.44.3: with an Azure disk on Azurite (below) and with the S3
disk of the new integration test.
A table with all its parts behind the cache disk (a policy with the
coldvolume only) fails the same way.Fix
DiskgetsAliases: the names of the cache wrappers collapsed into itssystem.disksrow(
groupUniqArrayIf(d.name, d.cache_path != '')).Disk.HasNameandclickhouse.FindDiskByNamematch a disk byits name or by an alias, the name of a disk wins over an alias of another disk.
The disk keeps the wrapped disk name, as before. It is the name stored in
metadata.json, inshadow/<db>/<table>/<disk>_<part>.tarand in<object_disk_path>/<backup>/<disk>/, so nothing changes inexisting backups, and an increment made after the server upgrade reuses the parts of a backup made before it.
Places where a disk name reported by the server is matched to the disk list:
filterPlainPolicyParts: the disk of a part is found by either name andDiskNameof the part is rewritten tothe name of the
Disk, solinkLocalPartsToShadowanduploadPlainDiskPartswork unchanged. An object diskwith local metadata behind a cache disk next to plain disks is still rejected, the error names both disks.
shouldSkipByDiskNameOrType:skip_disksskips the pair by either name. Before, only the wrapped disk nameworked.
rebalance(getLiveParts), the dry-run estimate ofcreateand the hardlink of existing parts indownload(
findHardlinkablePartsByHash,hardlinkFromLiveParts) resolvesystem.parts.disk_namethe same way.findDiskByNameis alias-aware, which also covers thesystem.storage_policieslookup of custom disks inresolveCustomDiskAliases(it used to fall back to matching by path).No new grants and no new server settings are needed.
Not affected: the regular FREEZE path doesn't use
system.parts.disk_nameto find a disk(
fetchHashOfAllFilesdoesn't filter by disk). An object disk with local metadata behind a cache disk is backedup on 26.8.44.3 by unpatched 2.8.3, checked.
Tests
Unit:
TestFilterPlainPolicyParts: parts behind a cache disk reported under the wrapped name (25.8) and under thecache name (26.8) resolve to the same disk, the returned parts carry the wrapped disk name; an object disk
behind a cache disk and a disk absent in
system.disksare rejected.TestSkipDisksMatchCacheAndWrappedDiskNames:skip_diskswith the wrapped name, the cache name, both, andskip_disk_types.TestDiskAliases,TestFindDiskByName.Integration:
TestPlainRewritableCacheHybridS3(new): the hybrid scenario ofTestPlainRewritableHybridS3with the coldvolume on a cache disk over
disk_s3_plain_rewritable, three runs:skip_disksby the cache disk name, by thewrapped disk name, and without
skip_disks(with restore on 25.11+). The cache disk and thes3_plain_rewritable_cache_hybridpolicy are added todynamic_settings.shfor 25.4+.TestCacheDiskBackup: additionally checks that the table metadata lists the parts behind the cache unders3_diskand never unders3_cache.Run locally (arm64):
TestPlainRewritableCacheHybridS3,TestPlainRewritableHybridS3andTestCacheDiskBackuppass on 26.8.44.3 and on 25.8.28.1. With the 2.8.3 binary
TestPlainRewritableCacheHybridS3fails on 26.8.44.3with the error above. The rest of the integration suite was not run locally.
Manual, one data volume upgraded from 25.8.28.1 to 26.8.44.3, Azure
plain_rewritabledisk on Azurite behind acache disk, both disk names in
skip_disks, three tables: local only, hybrid (parts on both volumes), all partsbehind the cache disk:
create_remotefull passes.create_remote --diff-from-remotefails with the error above.required_backuppoints to it, theparts unchanged since the full are
requiredunder the same disk name, only new parts are uploaded.rebaseof the next increment passes, the backup becomes full.restore_remoteof the chain and of the rebased backup into another database: the local and the hybrid tablecome back with the row counts of their local parts (the checksum of the hybrid table matches too), the table
behind the cache disk comes back as schema only, as it does with
skip_diskson 25.8.Also: the same
create_remoteby this branch on 25.8.28.1 gives the same parts, disks and remote files as 2.8.3;skip_diskswith the cache disk name only, on both versions; withoutskip_disksthe parts behind the cache arecopied under the wrapped disk name on both versions, an increment on 26.8 reuses the plain disk parts of a full
made on 25.8, and a full backup with plain disk parts restores on 26.8. With the same patch on top of v2.8.3,
watchwith a schedule,full_type=rebaseanddelete_previous_cyclecontinues the chain after the failed tickof 2.8.3.