Repository navigation
Refuse cross-database RENAME/EXCHANGE while DROP DATABASE is running - #132599
Marouane-elfadli wants to merge 13 commits into
Conversation
Refuse cross-database RENAME/EXCHANGE while DROP DATABASE runs
Add test 05330 for DROP DATABASE vs cross-database RENAME
|
@groeneai HEY CAN YOU TAKE A LOOK ON THIS pr if it's fix the issues for all the side ! ? |
|
I checked it on current master (
So the cross-database sides are fixed, including the exchange, which is worse than the issue says (it drops the other database's table). Other paths, from the code: every user-reachable cross-database move goes through What is left:
|
Updated comments to clarify the behavior of RENAME and EXCHANGE operations during a DROP DATABASE.
Updated comments for clarity regarding the behavior of RENAME/EXCHANGE operations during a DROP DATABASE process.
Fix formatting by adding a newline at the end of the file.
|
@groeneai so how about know if i need you to tell me is it good note me frome 1 to 20 ?/20 |
|
I re-checked the new head ( Done:
Left:
I'd rather not give a score. With these two fixed I see nothing else blocking; the review and the merge decision are up to the maintainers. CI has not run yet: it needs the |
|
@PedroTadim hi am sorry if i bother you i take time to fix this would you like if you have free time to take a look on it and thank you so much ! |
There was a problem hiding this comment.
@Marouane-elfadli why are you creating so many failpoints?
Closes: #132379
Related: #123694
Related: #51851
Related: #71333
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A
RENAME TABLEorEXCHANGE TABLESof the tables of a database no longer runs concurrently withDROP DATABASEof that database. Before, a table moved to another database during the drop was still shut down by it and stayed read-only (TABLE_IS_READ_ONLYforReplicatedMergeTree) and unable to merge (MergeTree) until a restart, and anEXCHANGEcould make the drop remove the wrong table. Such a rename is now refused withUNFINISHEDwhile the database is being dropped. Closes #132379.Description
DROP DATABASEcollects the storages of the database, callsflushAndPrepareForShutdownon them, then drops them by name. A concurrentRENAME/EXCHANGEcould change the tables of the database in between:RENAME TABLE a.t TO b.tmoved a prepared table to another database, where it stayed read-only / without merges after the drop succeeded.EXCHANGE TABLES a.t AND b.umade the drop remove the originalb.u, while the prepareda.tsurvived asb.u.RENAME TABLE a.t TO a.t2made the drop fail withDATABASE_NOT_EMPTYand left the prepared table unusable.DROP DATABASEalready holdsgetLockForDropDatabaseexclusively for the whole collect/prepare/drop phase. The fix makes everyRENAME/EXCHANGEtake a shared lock on all databases it touches (tryGetLockForRestartReplica) before taking its table guards:UNFINISHED;Changes:
InterpreterRenameQuery.cpp: the fix.InterpreterDropQuery.cpp,FailPoint.cpp: failpointdrop_database_holding_drop_lock, a pause point right afterprepare_tables, under the lock, used by the test. No behaviour change otherwise.05330_drop_database_blocks_cross_db_rename: pauses the drop after its tables are prepared, checks that cross-databaseRENAME/EXCHANGEand an in-databaseRENAMEof its tables are refused withUNFINISHEDwhile a rename inside the other database still works, then checks that the surviving table is writable and mergeable. The test fails without the fix.01150_ddl_guard_rwr: tolerates the new error code 341 (UNFINISHED), because the test races renames withDETACH DATABASE.