1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES

add_back_last_deleted_lock() was called when the lock was never
removed. Lock is removed in finalize_atomic_replace() in
close_all_tables_for_name(). finalize_atomic_replace() is done only
for successful operation.

In non-atomic codepath it drops the table first, if anything fails
later we don't need to return back the lock since there is no table
now. So the fix is required as well.
This commit is contained in:
Aleksey Midenkov
2022-08-31 11:55:05 +03:00
parent 24fff8267d
commit a228ec80e3
7 changed files with 112 additions and 17 deletions

View File

@ -65,3 +65,24 @@ create or replace table t1 (a int, b int, key k (a), key k (b));
--error ER_DUP_KEYNAME
create or replace table t1 (a int, b int, key k (a), key k (b));
drop table t1;
--echo #
--echo # MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES
--echo #
--echo # Non-atomic CREATE OR REPLACE part:
--echo #
set @saved_debug_dbug= @@session.debug_dbug;
set @@debug_dbug="+d,ddl_log_expensive_rename";
create table t1 (pk int primary key) engine=innodb;
create or replace table t2 (a int primary key references t1 (pk)) engine=innodb;
lock tables t1 write, t2 write;
--error ER_DUP_FIELDNAME
create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb;
select * from t1;
--error ER_TABLE_NOT_LOCKED
select * from t2;
unlock tables;
drop tables t1;
set @@debug_dbug= @saved_debug_dbug;