summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2018-07-03 01:07:53 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2018-07-03 01:07:53 +0530
commitde599d2c672c4078c8abf335ad0f59b818d360c6 (patch)
treed66001d89a31e812f8e91d14ee0e77dd22c7e51c /sql/sql_class.cc
parentfe76e68e0e858c6012ddd0bef6b24a4fbae828d2 (diff)
downloadmariadb-git-bb-10.3-MDEV-15855.tar.gz
MDEV-15855 Deadlock between purge thread and DDL statementbb-10.3-MDEV-15855
Problem: ========= Truncate operation holds MDL LOCK on the table (t1) and tries to acquire InnoDB dict_operation_lock. Purge holds InnoDB dict_operation_lock and tries to acquire MDL LOCK on the table (t1) to calculate the virtual column value. It leads to deadlock of purge and truncate table (DDL) Solution: ========= If purge tries to acquire MDL lock on the table then it should do the following: i) Purge should release all innodb locks (including dict_operation_lock) before acquiring metadata lock on the table. ii) After acquiring metadata lock on the table, it should check whether the table is dropped or renamed. If the table is dropped then purge should ignore the record. If the table is renamed then it should release the old table mdl lock and should acquire the new table mdl lock. iii) Once purge acquires mdl lock, it should use the server table for all the remaining virtual index for the purge record. - n_ref_count in dict_table_t does atomic operations for release, acquire, get_ref_count() - Introduce new virtual column information in purge_node_t to know whether the mdl lock acquired successfully.
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index d2e4f66dd59..e886727fe46 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -4779,6 +4779,11 @@ TABLE *get_purge_table(THD *thd)
return thd->open_tables;
}
+/** Close the purge table for purge thread. */
+void close_purge_table(THD* thd)
+{
+ close_thread_tables(thd);
+}
/** Find an open table in the list of prelocked tabled