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

@ -72,3 +72,22 @@ ERROR 42000: Duplicate key name 'k'
create or replace table t1 (a int, b int, key k (a), key k (b));
ERROR 42000: Duplicate key name 'k'
drop table t1;
#
# MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES
#
# Non-atomic CREATE OR REPLACE part:
#
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;
create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb;
ERROR 42S21: Duplicate column name 'c1'
select * from t1;
pk
select * from t2;
ERROR HY000: Table 't2' was not locked with LOCK TABLES
unlock tables;
drop tables t1;
set @@debug_dbug= @saved_debug_dbug;