summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Yang <jimmy.yang@oracle.com>2010-10-24 22:51:21 -0700
committerJimmy Yang <jimmy.yang@oracle.com>2010-10-24 22:51:21 -0700
commit1b5b5cbe65bd8f04373894c4c9535e157e2174e7 (patch)
tree71adf107689f5c873281589a6a50e21e0a2f2cd9
parent59f35ce808e3020efa9b0915397503679758bae6 (diff)
downloadmariadb-git-1b5b5cbe65bd8f04373894c4c9535e157e2174e7.tar.gz
Fix bug #57700 Latching order violation in row_truncate_table_for_mysql().
Approved by Sunny Bains
-rw-r--r--storage/innodb_plugin/ChangeLog6
-rw-r--r--storage/innodb_plugin/row/row0mysql.c23
2 files changed, 20 insertions, 9 deletions
diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog
index cccd5c0550a..9033e5557f3 100644
--- a/storage/innodb_plugin/ChangeLog
+++ b/storage/innodb_plugin/ChangeLog
@@ -1,3 +1,9 @@
+2010-10-24 The InnoDB Team
+
+ * row/row0mysql.c
+ Fix Bug #57700 Latching order violation in
+ row_truncate_table_for_mysql()
+
2010-10-20 The InnoDB Team
* dict/dict0load.c
diff --git a/storage/innodb_plugin/row/row0mysql.c b/storage/innodb_plugin/row/row0mysql.c
index 107af481b79..827be32bdf7 100644
--- a/storage/innodb_plugin/row/row0mysql.c
+++ b/storage/innodb_plugin/row/row0mysql.c
@@ -2771,15 +2771,6 @@ row_truncate_table_for_mysql(
trx->table_id = table->id;
- /* Lock all index trees for this table, as we will
- truncate the table/index and possibly change their metadata.
- All DML/DDL are blocked by table level lock, with
- a few exceptions such as queries into information schema
- about the table, MySQL could try to access index stats
- for this kind of query, we need to use index locks to
- sync up */
- dict_table_x_lock_indexes(table);
-
if (table->space && !table->dir_path_of_temp_table) {
/* Discard and create the single-table tablespace. */
ulint space = table->space;
@@ -2792,6 +2783,11 @@ row_truncate_table_for_mysql(
dict_hdr_get_new_id(NULL, NULL, &space);
+ /* Lock all index trees for this table. We must
+ do so after dict_hdr_get_new_id() to preserve
+ the latch order */
+ dict_table_x_lock_indexes(table);
+
if (space == ULINT_UNDEFINED
|| fil_create_new_single_table_tablespace(
space, table->name, FALSE, flags,
@@ -2825,6 +2821,15 @@ row_truncate_table_for_mysql(
FIL_IBD_FILE_INITIAL_SIZE, &mtr);
mtr_commit(&mtr);
}
+ } else {
+ /* Lock all index trees for this table, as we will
+ truncate the table/index and possibly change their metadata.
+ All DML/DDL are blocked by table level lock, with
+ a few exceptions such as queries into information schema
+ about the table, MySQL could try to access index stats
+ for this kind of query, we need to use index locks to
+ sync up */
+ dict_table_x_lock_indexes(table);
}
/* scan SYS_INDEXES for all indexes of the table */