From c75e92fd6f66d6b4fcb0972965c34fe8ff225770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 17 Oct 2013 12:17:32 +0300 Subject: [PATCH] MDEV-5141: Failing assertion: ib_table->stat_initialized in file ha_innodb.cc line 11042 on concurrent ALTER and SELECT from I_S Analysis: After ALTER TABLE the table statistics needs to be rebuilt and therefore stat_initialized is set false. It will be rebuilt when the table is loaded again and table is closed when alter table is completed. However, during alter table table could be used by concurrent SELECT from I_S. Therefore, we need to rebuild transient table statistics meanwhile until table can be reloaded. --- storage/innobase/row/row0mysql.cc | 11 ++++++++--- storage/xtradb/row/row0mysql.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index f46d202eed8..81d605e9e86 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -5004,9 +5004,14 @@ end: } else { if (old_is_tmp && !new_is_tmp) { /* After ALTER TABLE the table statistics - needs to be rebuilt. It will be rebuilt - when the table is loaded again. */ - table->stat_initialized = FALSE; + needs to be rebuilt. Even if we close + table below there could be other + transactions using this table (e.g. + SELECT * FROM INFORMATION_SCHEMA.`TABLE_CONSTRAINTS`), + thus we can't remove table from dictionary cache + here. Therefore, we initialize the + transient statistics here. */ + dict_stats_update_transient(table); } } } diff --git a/storage/xtradb/row/row0mysql.c b/storage/xtradb/row/row0mysql.c index 49ee3d91ed4..ededbd393b1 100644 --- a/storage/xtradb/row/row0mysql.c +++ b/storage/xtradb/row/row0mysql.c @@ -4295,9 +4295,14 @@ end: } else { if (old_is_tmp && !new_is_tmp) { /* After ALTER TABLE the table statistics - needs to be rebuilt. It will be rebuilt - when the table is loaded again. */ - table->stat_initialized = FALSE; + needs to be rebuilt. Even if we close + table below there could be other + transactions using this table (e.g. + SELECT * FROM INFORMATION_SCHEMA.`TABLE_CONSTRAINTS`), + thus we can't remove table from dictionary cache + here. Therefore, we initialize the + transient statistics here. */ + dict_stats_update_transient(table); } } }