Repository navigation
Fix server startup after an interrupted CREATE OR REPLACE on a non-atomic database disk - #123902
Conversation
…atomic database disk On a database disk without atomic renames (`plain_rewritable` object storage), the rename of the temporary `_tmp_replace_*` table of `CREATE OR REPLACE` copies the metadata file and then removes the source. If the server is killed in between, two metadata files refer to the same table, and the server fails to start with `Mapping for table with UUID=... already exists`. This became frequent since union system log tables are created by default with `CREATE OR REPLACE` at the first flush after startup, and `test_reloading_storage_configuration` restarts the server with `kill -9`. Now the metadata files of `_tmp_replace_*` tables are processed after the others, and if such a file has the same UUID as another table in the database, it is removed (only the metadata file, as the data is addressed by the UUID). CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=446d1bb88275a0bccf37e0187ee94a769e00dce8&name_0=MasterCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%206%2F8%29 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [11b751f] Summary: ✅
AI ReviewSummaryThis PR defers Final Verdict
LLVM Coverage Report |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 18 s compile time in total, 7 of them have a recent master baseline. |
alexey-milovidov
left a comment
There was a problem hiding this comment.
The test is quite ad-hoc. Passable.
Instead of removing a stray file, we can rename it for safety, as we usually do.
However, this is good to merge.
…emporary-table-unrelated-name Fix test_copy_of_temporary_table_under_unrelated_name after the duplicate-UUID rule of ClickHouse#123902
…e#123902 The arm was added by ClickHouse#123832, whose CI ran before ClickHouse#123902 was merged. ClickHouse#123902 makes `DatabaseOrdinary::loadTablesMetadata` remove a deferred `_tmp_replace_*` metadata file whose UUID matches any table of the database, whatever its name, and its test 05325 expects the server to start in that case. So a copy of the temporary table's metadata under an unrelated name (`u.sql`) is no longer a UUID collision: the server starts, and the arm's `start_clickhouse(expected_to_fail=True)` failed on every master run. The arm now expects the start with `t` and `u` (which keeps the data), the temporary file removed, and the message of the ClickHouse#123902 rule for this file. That message can only be logged if the copy rule of ClickHouse#123832 left the file alone, so the arm still checks that the copy rule only handles destinations of the temporary table's own moves. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Hello i am investgating this issue #127232 |
|
|
#123902 is not mine, so this is from its code and description. Why #124937 is still open (changes requested). It covers another leftover: an Dropping them: I agree. A
|
On a database disk without atomic renames (
plain_rewritableobject storage), the rename of the temporary_tmp_replace_*table ofCREATE OR REPLACEcopies the metadata file and then removes the source. If the server is killed in between, two metadata files refer to the same table, and the server cannot start anymore:This became frequent in CI after union system log tables (
system.all_*) were enabled by default: they are created withCREATE OR REPLACEat the first flush after each startup, andtest_reloading_storage_configurationrestarts the server withkill -9many times.Now the metadata files of
_tmp_replace_*tables are processed after all others, and if such a file has the same UUID as another table in the same database, only this metadata file is removed (the data is addressed by the UUID). For both the interrupted plain rename and the interrupted exchange, keeping the file under the final name gives a consistent state.CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=446d1bb88275a0bccf37e0187ee94a769e00dce8&name_0=MasterCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%206%2F8%29
CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=a537662755efda42670a7a6afa440a1519f5d736&name_0=MasterCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%206%2F8%29
Related: #117943
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix server startup failure with
Mapping for table with UUID=... already existsafter the server was killed duringCREATE OR REPLACE TABLEwhen database metadata is stored on an object storage disk (database_diskwithplain_rewritable).🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/123902]
Version info
26.10.1.1906-master(included in26.10and later)