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

@ -5414,7 +5414,8 @@ bool select_create::send_eof()
mysql_unlock_tables(thd, lock);
}
else if (atomic_replace && create_info->pos_in_locked_tables &&
create_info->finalize_locked_tables(thd))
/* send_eof() is done on success, passing false here */
create_info->finalize_locked_tables(thd, false))
DBUG_RETURN(true);
send_ok_packet();
@ -5526,6 +5527,7 @@ void select_create::abort_result_set()
thd->locked_tables_list.unlock_locked_table(thd, create_info->mdl_ticket);
}
else if (atomic_replace && create_info->pos_in_locked_tables)
(void) create_info->finalize_locked_tables(thd);
/* abort_result_set() is done on error, passing true here */
(void) create_info->finalize_locked_tables(thd, true);
DBUG_VOID_RETURN;
}