From 9405fdeb9ee63ad5bb48a16c7ddf2ad66b84087d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 21 Nov 2017 17:52:17 +0200 Subject: [PATCH] MDEV-13201 Assertion `srv_undo_sources || ...` failed on shutdown during DDL operation dict_stats_exec_sql(): Refuse the operation if shutdown has been initiated. The real fix would be to update the persistent statistics as part of the data dictionary transactions. To do this, we should move the storage of InnoDB persistent statistics to the InnoDB data files, and maybe also remove the InnoDB data dictionary. --- .../suite/innodb/r/truncate_restart.result | 13 +++++++++++++ .../suite/innodb/t/truncate_restart.test | 18 ++++++++++++++++++ storage/innobase/dict/dict0stats.cc | 5 ++++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/innodb/r/truncate_restart.result create mode 100644 mysql-test/suite/innodb/t/truncate_restart.test diff --git a/mysql-test/suite/innodb/r/truncate_restart.result b/mysql-test/suite/innodb/r/truncate_restart.result new file mode 100644 index 00000000000..169a56a004e --- /dev/null +++ b/mysql-test/suite/innodb/r/truncate_restart.result @@ -0,0 +1,13 @@ +call mtr.add_suppression("InnoDB: Cannot save table statistics for table `test`\\.`t1`: Persistent statistics do not exist"); +SET GLOBAL innodb_stats_persistent= ON; +CREATE TABLE t1 (t TEXT) ENGINE=InnoDB; +connect con1,localhost,root,,test; +SET DEBUG_SYNC='ib_trunc_table_trunc_completing SIGNAL committed WAIT_FOR ever'; +TRUNCATE TABLE t1; +connection default; +SET DEBUG_SYNC='now WAIT_FOR committed'; +disconnect con1; +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/truncate_restart.test b/mysql-test/suite/innodb/t/truncate_restart.test new file mode 100644 index 00000000000..92f09ac89b1 --- /dev/null +++ b/mysql-test/suite/innodb/t/truncate_restart.test @@ -0,0 +1,18 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +call mtr.add_suppression("InnoDB: Cannot save table statistics for table `test`\\.`t1`: Persistent statistics do not exist"); + +SET GLOBAL innodb_stats_persistent= ON; +CREATE TABLE t1 (t TEXT) ENGINE=InnoDB; +--connect (con1,localhost,root,,test) +SET DEBUG_SYNC='ib_trunc_table_trunc_completing SIGNAL committed WAIT_FOR ever'; +--send +TRUNCATE TABLE t1; +--connection default +SET DEBUG_SYNC='now WAIT_FOR committed'; +--source include/restart_mysqld.inc +--disconnect con1 +SELECT COUNT(*) FROM t1; +DROP TABLE t1; diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index 2ea482095ce..7584effee9e 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -293,7 +293,10 @@ dict_stats_exec_sql( ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X)); ut_ad(mutex_own(&dict_sys->mutex)); - if (!dict_stats_persistent_storage_check(true)) { + extern bool dict_stats_start_shutdown; + + if (dict_stats_start_shutdown + || !dict_stats_persistent_storage_check(true)) { pars_info_free(pinfo); return(DB_STATS_DO_NOT_EXIST); }