[Commits] b3fe5c1: MDEV-10555: Server crashes in mysql_admin_table upon killing ANALYZE

Oleksandr Byelkin sanja at mariadb.com
Mon Mar 13 16:01:15 EET 2017


revision-id: b3fe5c10a932ab8da8768cc51ab4ee8505f10a18 (mariadb-10.2.4-47-gb3fe5c1)
parent(s): ad24dc2bff951fb56c1eae15bc54c9401bd7417b
committer: Oleksandr Byelkin
timestamp: 2017-03-13 15:01:15 +0100
message:

MDEV-10555: Server crashes in mysql_admin_table upon killing ANALYZE

test suite

---
 mysql-test/r/analyze_debug.result | 10 ++++++++++
 mysql-test/t/analyze_debug.test   | 13 +++++++++++++
 sql/sql_admin.cc                  | 17 +++++++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/mysql-test/r/analyze_debug.result b/mysql-test/r/analyze_debug.result
new file mode 100644
index 0000000..2a11578
--- /dev/null
+++ b/mysql-test/r/analyze_debug.result
@@ -0,0 +1,10 @@
+SET @save_use_stat_tables= @@use_stat_tables;
+SET use_stat_tables= PREFERABLY;
+CREATE TABLE t1 (a int);
+insert into t1 values (1),(2),(3);
+SET STATEMENT debug_dbug="d,fail_2call_open_only_one_table" for
+ANALYZE TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	Operation failed
+drop table t1;
+SET use_stat_tables= @save_use_stat_tables;
diff --git a/mysql-test/t/analyze_debug.test b/mysql-test/t/analyze_debug.test
new file mode 100644
index 0000000..684011c
--- /dev/null
+++ b/mysql-test/t/analyze_debug.test
@@ -0,0 +1,13 @@
+
+--source include/have_debug.inc
+
+SET @save_use_stat_tables= @@use_stat_tables;
+SET use_stat_tables= PREFERABLY;
+CREATE TABLE t1 (a int);
+insert into t1 values (1),(2),(3);
+
+SET STATEMENT debug_dbug="d,fail_2call_open_only_one_table" for
+ANALYZE TABLE t1;
+
+drop table t1;
+SET use_stat_tables= @save_use_stat_tables;
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 4f87335..95c2163 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -295,6 +295,10 @@ static inline bool table_not_corrupt_error(uint sql_errno)
           sql_errno == ER_WRONG_OBJECT);
 }
 
+#ifndef DBUG_OFF
+// It is counter for debugging fail on second call of open_only_one_table
+static int debug_fail_counter= 0;
+#endif
 
 static bool open_only_one_table(THD* thd, TABLE_LIST* table,
                                 bool repair_table_use_frm,
@@ -319,6 +323,16 @@ static bool open_only_one_table(THD* thd, TABLE_LIST* table,
   lex->query_tables_last= &table->next_global;
   lex->query_tables_own_last= 0;
 
+  DBUG_EXECUTE_IF("fail_2call_open_only_one_table", {
+                  if (debug_fail_counter)
+                  {
+                    open_error= TRUE;
+                    goto dbug_err;
+                  }
+                  else
+                    debug_fail_counter++;
+                  });
+
   /*
     CHECK TABLE command is allowed for views as well. Check on alter flags
     to differentiate from ALTER TABLE...CHECK PARTITION on which view is not
@@ -378,6 +392,9 @@ static bool open_only_one_table(THD* thd, TABLE_LIST* table,
     open_error= (thd->open_temporary_tables(table) ||
                  open_and_lock_tables(thd, table, TRUE, 0));
   }
+
+dbug_err:
+
   thd->prepare_derived_at_open= FALSE;
 
   /*


More information about the commits mailing list