Repository navigation
Tests for #83219 issue - #83220
Closed
orloffv wants to merge 1 commit into
Closed
Tests for #83219 issue#83220orloffv wants to merge 1 commit into
orloffv wants to merge 1 commit into
Conversation
Contributor
|
Workflow [PR], commit [862c760] Summary: ❌
|
Member
pamarcos
self-requested a review
July 4, 2025 07:33
Contributor
Author
Member
|
The code was added by @kitaisreal, let's invite him to fix. |
Member
|
We didn't receive help from @kitaisreal |
pull Bot
pushed a commit
to Haofei/ClickHouse
that referenced
this pull request
Aug 5, 2026
… name Creating two ENGINE = Backup databases from the same backup left the second one's tables silently empty, and dropping such a database and recreating it under a different name did the same, so a database could not be restored from a backup under a new name without restarting the server. buildStoragePolicyName keyed the policy on the in-backup database name and the backup destination only. The local database name was absent from the key, yet the value cached under it depends on the local name: the policy's DiskBackup is built with path_prefix_replacement.from = data_path, that is data/<local name>/. Context::getOrCreateStoragePolicy is get-or-create, so on a key hit the creator lambda never runs and the second database adopts the first one's disk. DiskBackup::replacePathPrefix returns the path unchanged when the prefix does not match, so the second database's part lookups resolve to paths that are not in the backup, and its tables load with zero parts without any error. Add the local database name to the name, and derive the whole name as a sipHash128 over the length-prefixed triple (local name, in-backup name, destination). Hashing rather than joining with a delimiter matters here: escapeForFileName does not escape '_', which is ubiquitous in database names, so a '_'-joined key collides for ordinary name pairs such as local "x" plus in-backup "y_z" against local "x_y" plus in-backup "z", and a collision in this key reproduces exactly the silent wrong-results bug being fixed. Length prefixing keeps field boundaries unambiguous. DiskFromAST names generated disks the same way and for the same reason, since the name has to come out identical on every open of the same database. Nothing persists the name: DatabaseBackup never writes a table .sql, it reads them out of the backup and rewrites the AST in memory, and getCreateDatabaseQueryImpl regenerates CREATE DATABASE from the config without mentioning a policy. So the changed spelling needs no upgrade or downgrade path, no SettingsChangesHistory entry, and no versioning. A database created by an older server picks up the fix when it is opened. As a side effect the policy name no longer embeds the backup destination verbatim. BackupInfo::toString formats with secrets shown, so with an S3 destination the previous name carried the credentials into each table's storage_policy setting and into system.storage_policies. The integration test test_multiple_databases_from_same_backup was written by @orloffv in the test-only pull request ClickHouse#83220. Closes: ClickHouse#83219
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.
Changelog category (leave one):
Trying to reproduce #83219