mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fixed deadlock with LOCK TABLES and ALTER TABLE
MDEV-21398 Deadlock (server hang) or assertion failure in Diagnostics_area::set_error_status upon ALTER under lock This failure could only happen if one locked the same table multiple times and then did an ALTER TABLE on the table. Major change is to change all instances of table->m_needs_reopen= true; to table->mark_table_for_reopen(); The main fix for the problem was to ensure that we mark all instances of the table in the locked_table_list and when we reopen the tables, we first close all tables before reopening and locking them. Other things: - Don't call thd->locked_tables_list.reopen_tables if there are no tables marked for reopen. (performance)
This commit is contained in:
@ -1823,20 +1823,23 @@ private:
|
||||
TABLE_LIST *m_locked_tables;
|
||||
TABLE_LIST **m_locked_tables_last;
|
||||
/** An auxiliary array used only in reopen_tables(). */
|
||||
TABLE **m_reopen_array;
|
||||
TABLE_LIST **m_reopen_array;
|
||||
/**
|
||||
Count the number of tables in m_locked_tables list. We can't
|
||||
rely on thd->lock->table_count because it excludes
|
||||
non-transactional temporary tables. We need to know
|
||||
an exact number of TABLE objects.
|
||||
*/
|
||||
size_t m_locked_tables_count;
|
||||
uint m_locked_tables_count;
|
||||
public:
|
||||
bool some_table_marked_for_reopen;
|
||||
|
||||
Locked_tables_list()
|
||||
:m_locked_tables(NULL),
|
||||
m_locked_tables_last(&m_locked_tables),
|
||||
m_reopen_array(NULL),
|
||||
m_locked_tables_count(0)
|
||||
m_locked_tables_count(0),
|
||||
some_table_marked_for_reopen(0)
|
||||
{
|
||||
init_sql_alloc(&m_locked_tables_root, MEM_ROOT_BLOCK_SIZE, 0,
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
@ -1859,6 +1862,7 @@ public:
|
||||
bool restore_lock(THD *thd, TABLE_LIST *dst_table_list, TABLE *table,
|
||||
MYSQL_LOCK *lock);
|
||||
void add_back_last_deleted_lock(TABLE_LIST *dst_table_list);
|
||||
void mark_table_for_reopen(THD *thd, TABLE *table);
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user