diff options
author | Monty <monty@mariadb.org> | 2020-05-22 18:02:24 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2020-05-23 14:58:33 +0300 |
commit | be647ff14d6196af825f05020acee8f18af4773d (patch) | |
tree | df9a139f33c72f943671272f4c99ab8e23a4f093 /sql/sql_table.cc | |
parent | 6462af1c2e2cddf3a96818dc7884e187d8ba7f24 (diff) | |
download | mariadb-git-be647ff14d6196af825f05020acee8f18af4773d.tar.gz |
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)
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e53d51777b4..8d81911bf29 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -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); } |