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 <noreply@anthropic.com>
|
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.
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)