diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2015-04-01 13:28:08 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2015-04-01 13:28:08 +0400 |
commit | 8d7e452bf3c980d21e67c207bd97eea6035bd2b0 (patch) | |
tree | d86499920062e907a1b143d58b1769ab5e060a4c /sql/sql_table.cc | |
parent | cbc5157feb9801310e458f7ed10983ad478c881e (diff) | |
download | mariadb-git-bb-mdev7894.tar.gz |
MDEV-7894 - ALTER TABLE ... IMPORT/DISCARD TABLESPACE under LOCK TABLES doesn'tbb-mdev7894
acquire X metadata lock
Due to coding mistake thr_lock.c lock was necessary to isolate ALTER TABLE
IMPORT/DISCARD TABLESPACE under LOCK TABLES from concurrent I_S queries/
open HANDLERs.
Change ALTER TABLE IMPORT/DISCARD TABLESPACE code to acquire X
lock on table being imported/discarded even under lock tables.
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c4b07ad2035..b4cbc936fa1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5561,6 +5561,24 @@ int mysql_discard_or_import_tablespace(THD *thd, DBUG_RETURN(-1); } + /* + Under LOCK TABLES we need to upgrade SNRW metadata lock to X lock + before doing discard or import of tablespace. + + Skip this step for temporary tables as metadata locks are not + applicable for them. + */ + if (table_list->table->s->tmp_table == NO_TMP_TABLE && + (thd->locked_tables_mode == LTM_LOCK_TABLES || + thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES) && + thd->mdl_context.upgrade_shared_lock(table_list->table->mdl_ticket, + MDL_EXCLUSIVE, + thd->variables.lock_wait_timeout)) + { + thd->tablespace_op= FALSE; + DBUG_RETURN(-1); + } + error= table_list->table->file->ha_discard_or_import_tablespace(discard); THD_STAGE_INFO(thd, stage_end); @@ -5583,6 +5601,13 @@ int mysql_discard_or_import_tablespace(THD *thd, error= write_bin_log(thd, FALSE, thd->query(), thd->query_length()); err: + if (table_list->table->s->tmp_table == NO_TMP_TABLE && + (thd->locked_tables_mode == LTM_LOCK_TABLES || + thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)) + { + table_list->table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); + } + thd->tablespace_op=FALSE; if (error == 0) |