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:
@ -7783,7 +7783,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
|
||||
if (field->default_value)
|
||||
field->default_value->expr->walk(&Item::rename_fields_processor, 1,
|
||||
&column_rename_param);
|
||||
table->m_needs_reopen= 1; // because new column name is on thd->mem_root
|
||||
// Force reopen because new column name is on thd->mem_root
|
||||
table->mark_table_for_reopen();
|
||||
}
|
||||
|
||||
/* Check if field is changed */
|
||||
@ -8195,7 +8196,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
|
||||
{
|
||||
check->expr->walk(&Item::rename_fields_processor, 1,
|
||||
&column_rename_param);
|
||||
table->m_needs_reopen= 1; // because new column name is on thd->mem_root
|
||||
// Force reopen because new column name is on thd->mem_root
|
||||
table->mark_table_for_reopen();
|
||||
}
|
||||
new_constraint_list.push_back(check, thd->mem_root);
|
||||
}
|
||||
|
Reference in New Issue
Block a user