summaryrefslogtreecommitdiff
path: root/storage/innobase/row/row0mysql.c
diff options
context:
space:
mode:
authorJimmy Yang <jimmy.yang@oracle.com>2010-08-24 20:42:33 -0700
committerJimmy Yang <jimmy.yang@oracle.com>2010-08-24 20:42:33 -0700
commit224261eec5cef02a57e54621bcddc5a07a262d9f (patch)
treece32cb1bd9da6c9fa76a7a8ea0e93b6e6d2b315b /storage/innobase/row/row0mysql.c
parent0012d0d884b5ab8097d3b2fcda3a58dfe0ba6375 (diff)
downloadmariadb-git-224261eec5cef02a57e54621bcddc5a07a262d9f.tar.gz
This is to resolve a hang situation in 5.1 builtin raised by
bug #49251 (deadlock/crash with concurrent truncate table and index statistics calculation) by backporting a solution from #54678 fixed for 5.1 plugin and 5.5.
Diffstat (limited to 'storage/innobase/row/row0mysql.c')
-rw-r--r--storage/innobase/row/row0mysql.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c
index 3b76ffa76f1..aae4703737b 100644
--- a/storage/innobase/row/row0mysql.c
+++ b/storage/innobase/row/row0mysql.c
@@ -2830,6 +2830,15 @@ 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);
+
/* scan SYS_INDEXES for all indexes of the table */
heap = mem_heap_create(800);
@@ -2902,6 +2911,10 @@ next_rec:
mem_heap_free(heap);
+ /* Done with index truncation, release index tree locks,
+ subsequent work relates to table level metadata change */
+ dict_table_x_unlock_indexes(table);
+
new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
info = pars_info_create();