Skip to content

Tests for #83219 issue - #83220

Closed
orloffv wants to merge 1 commit into
ClickHouse:masterfrom
orloffv:patch-8
Closed

orloffv wants to merge 1 commit into
ClickHouse:masterfrom
orloffv:patch-8

Conversation

@orloffv

@orloffv orloffv commented Jul 3, 2025

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Trying to reproduce #83219

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 4, 2025
@clickhouse-gh

clickhouse-gh Bot commented Jul 4, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [862c760]

Summary: ❌

job_name test_name status info comment
Integration tests (asan, old analyzer, 1/6) failure
test_database_backup/test.py::test_multiple_databases_from_same_backup[Disk(backup_disk_s3_plain, test_database_backup)] FAIL
Integration tests (release, 3/4) failure
test_database_backup/test.py::test_multiple_databases_from_same_backup[Disk(backup_disk_s3_plain, test_database_backup)] FAIL
Integration tests (aarch64, distributed plan, 3/4) failure
test_database_backup/test.py::test_multiple_databases_from_same_backup[Disk(backup_disk_s3_plain, test_database_backup)] FAIL
Integration tests (tsan, 1/6) failure
test_database_backup/test.py::test_multiple_databases_from_same_backup[Disk(backup_disk_s3_plain, test_database_backup)] FAIL
Integration tests (asan, flaky check) failure
test_database_backup/test.py::test_multiple_databases_from_same_backup[Disk(backup_disk_s3_plain, test_database_backup)-1-3] FAIL
test_database_backup/test.py::test_database_backup_database[File(test_database_backup_file)-3-3] FAIL
test_database_backup/test.py::test_database_backup_database[File(test_database_backup_file)-2-3] FAIL
test_database_backup/test.py::test_database_backup_database[Disk(backup_disk_local, test_database_backup)-3-3] FAIL
test_database_backup/test.py::test_database_backup_table[Disk(backup_disk_object_storage_local_plain, test_table_backup)-3-3] FAIL
test_database_backup/test.py::test_database_backup_database[Disk(backup_disk_object_storage_local_plain, test_database_backup)-1-3] FAIL
test_database_backup/test.py::test_multiple_databases_from_same_backup[Disk(backup_disk_s3_plain, test_database_backup)-2-3] FAIL
test_database_backup/test.py::test_database_backup_table[Disk(backup_disk_s3_plain, test_table_backup)-3-3] FAIL
test_database_backup/test.py::test_database_backup_database[Disk(backup_disk_object_storage_local_plain, test_database_backup)-3-3] FAIL
test_database_backup/test.py::test_database_backup_database[Disk(backup_disk_s3_plain, test_database_backup)-2-3] FAIL
test_database_backup/test.py::test_database_backup_table[Disk(backup_disk_local, test_table_backup)-3-3] FAIL
test_database_backup/test.py::test_database_backup_database[File(test_database_backup_file)-1-3] FAIL
test_database_backup/test.py::test_database_backup_table[File(test_table_backup_file)-1-3] FAIL
test_database_backup/test.py::test_database_backup_database[Disk(backup_disk_object_storage_local_plain, test_database_backup)-2-3] FAIL
test_database_backup/test.py::test_database_backup_database[Disk(backup_disk_local, test_database_backup)-1-3] FAIL
test_database_backup/test.py::test_database_backup_table[Disk(backup_disk_object_storage_local_plain, test_table_backup)-2-3] FAIL
test_database_backup/test.py::test_database_backup_table[File(test_table_backup_file)-2-3] FAIL
test_database_backup/test.py::test_database_backup_table[File(test_table_backup_file)-3-3] FAIL
test_database_backup/test.py::test_database_backup_database[Disk(backup_disk_s3_plain, test_database_backup)-1-3] FAIL
test_database_backup/test.py::test_database_backup_table[Disk(backup_disk_s3_plain, test_table_backup)-2-3] FAIL
test_database_backup/test.py::test_multiple_databases_from_same_backup[Disk(backup_disk_s3_plain, test_database_backup)-3-3] FAIL
test_database_backup/test.py::test_database_backup_table[Disk(backup_disk_local, test_table_backup)-2-3] FAIL
test_database_backup/test.py::test_database_backup_database[Disk(backup_disk_s3_plain, test_database_backup)-3-3] FAIL
test_database_backup/test.py::test_database_backup_table[Disk(backup_disk_s3_plain, test_table_backup)-1-3] FAIL

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jul 4, 2025
@pamarcos

pamarcos commented Jul 4, 2025

Copy link
Copy Markdown
Member

Thanks for your contribution and the detailed explanation of the issue in #83219 @orloffv!

The test looks fine and seems to reproduce the issue. However, we cannot merge the test without the fix. Do you want to try to address that yourself in this same PR? 💪

@pamarcos
pamarcos self-requested a review July 4, 2025 07:33
@orloffv

orloffv commented Jul 4, 2025

Copy link
Copy Markdown
Contributor Author

@pamarcos
Unfortunately, I don't know how to write in C++ and don't understand where exactly the problem is in the code.
But this issue it's more important i think
#83188

@alexey-milovidov

Copy link
Copy Markdown
Member

The code was added by @kitaisreal, let's invite him to fix.

@alexey-milovidov

Copy link
Copy Markdown
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants