Commit 16398736 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-18154 Deadlock and assertion upon no-op ALTER under LOCK TABLES

1. Revert incorrect treatment of m_needs_reopen;
2. Close single instance of TABLE instead of all instances since
   reopened only those that are marked for reopen.
parent 395e1dcd
...@@ -2488,9 +2488,16 @@ Locked_tables_list::reopen_tables(THD *thd, bool need_reopen) ...@@ -2488,9 +2488,16 @@ Locked_tables_list::reopen_tables(THD *thd, bool need_reopen)
{ {
if (!table_list->table || !table_list->table->needs_reopen()) if (!table_list->table || !table_list->table->needs_reopen())
continue; continue;
/* no need to remove the table from the TDC here, thus (TABLE*)1 */ for (TABLE **prev= &thd->open_tables; *prev; prev= &(*prev)->next)
close_all_tables_for_name(thd, table_list->table->s, {
HA_EXTRA_NOT_USED, (TABLE*)1); if (*prev == table_list->table)
{
thd->locked_tables_list.unlink_from_list(thd, table_list, false);
mysql_lock_remove(thd, thd->lock, *prev);
close_thread_table(thd, prev);
break;
}
}
DBUG_ASSERT(table_list->table == NULL); DBUG_ASSERT(table_list->table == NULL);
} }
else else
......
...@@ -7831,7 +7831,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, ...@@ -7831,7 +7831,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
Create_field *def; Create_field *def;
Field **f_ptr,*field; Field **f_ptr,*field;
MY_BITMAP *dropped_fields= NULL; // if it's NULL - no dropped fields MY_BITMAP *dropped_fields= NULL; // if it's NULL - no dropped fields
bool save_reopen= table->m_needs_reopen;
DBUG_ENTER("mysql_prepare_alter_table"); DBUG_ENTER("mysql_prepare_alter_table");
/* /*
...@@ -8511,9 +8510,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, ...@@ -8511,9 +8510,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
alter_info->create_list.swap(new_create_list); alter_info->create_list.swap(new_create_list);
alter_info->key_list.swap(new_key_list); alter_info->key_list.swap(new_key_list);
alter_info->check_constraint_list.swap(new_constraint_list); alter_info->check_constraint_list.swap(new_constraint_list);
DBUG_RETURN(rc);
err: err:
table->m_needs_reopen= save_reopen;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment