summaryrefslogtreecommitdiff
path: root/storage/innobase/include/row0types.h
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2018-07-06 17:13:53 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-07-06 17:13:53 +0300
commit8b0d4cff0760b0a35285c315d82c49631c108baf (patch)
treee04a349e07fb23b7db1095f330d1c61dccdf1192 /storage/innobase/include/row0types.h
parente3207b6c132666e734adcd6e4c8485b1580039c4 (diff)
downloadmariadb-git-8b0d4cff0760b0a35285c315d82c49631c108baf.tar.gz
MDEV-15855 Deadlock between purge thread and DDL statement
Problem: ======== Truncate operation holds MDL on the table (t1) and tries to acquire InnoDB dict_operation_lock. Purge holds dict_operation_lock and tries to acquire MDL on the table (t1) to evaluate virtual column expressions for indexed virtual columns. It leads to deadlock of purge and truncate table (DDL). Solution: ========= If purge tries to acquire MDL on the table then it should do the following: i) Purge should release all innodb latches (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 was dropped or renamed. If the table is dropped then purge should ignore the undo log record. If the table is renamed then it should release the old MDL and acquire MDL on the new name. iii) Once purge acquires MDL, it should use the SQL table handle for all the remaining virtual index for the purge record. purge_node_t: Introduce new virtual column information to know whether the MDL was acquired successfully. This is joint work with Marko Mäkelä.
Diffstat (limited to 'storage/innobase/include/row0types.h')
-rw-r--r--storage/innobase/include/row0types.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/storage/innobase/include/row0types.h b/storage/innobase/include/row0types.h
index 52c89cb01fa..1bff3767253 100644
--- a/storage/innobase/include/row0types.h
+++ b/storage/innobase/include/row0types.h
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -52,4 +53,55 @@ struct row_log_t;
/* MySQL data types */
struct TABLE;
+/** Purge virtual column node information. */
+struct purge_vcol_info_t
+{
+ /** Is there a possible need to evaluate virtual columns? */
+ bool requested;
+ /** Do we have to evaluate virtual columns (using mariadb_table)? */
+ bool used;
+
+ /** True if it is used for the first time. */
+ bool first_use;
+
+ /** MariaDB table opened for virtual column computation. */
+ TABLE* mariadb_table;
+
+ /** Reset the state. */
+ void reset()
+ {
+ requested = false;
+ used = false;
+ first_use = false;
+ mariadb_table = NULL;
+ }
+
+ /** Validate the virtual column information.
+ @return true if the mariadb table opened successfully
+ or doesn't try to calculate virtual column. */
+ bool validate() const { return !used || mariadb_table; }
+
+ /** Note that the virtual column information is needed. */
+ void set_used()
+ {
+ ut_ad(requested);
+
+ if (first_use) {
+ first_use = false;
+ ut_ad(used);
+ return;
+ }
+
+ first_use = used = true;
+ }
+
+ /** Check whether it fetches mariadb table for the first time.
+ @return true if first time tries to open mariadb table. */
+ bool is_first_fetch() const
+ {
+ ut_ad(!first_use || used);
+ return first_use;
+ }
+};
+
#endif