summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-08-20 17:50:34 +0300
committerMonty <monty@mariadb.org>2018-08-20 18:50:30 +0300
commit38ecd541e887bef151860030a0c1978393d932a2 (patch)
treec98317e511aff8a7be8f3871f8fa5c59d8c51401
parentee98e95e25bc8abe2be61d3449974d8ba078b351 (diff)
downloadmariadb-git-38ecd541e887bef151860030a0c1978393d932a2.tar.gz
MDEV-16986 Unitialized mutex, SIGSEGV and assorted assertion failures in Aria code
The problem was that when a mysql.proc table was opened for reading it was added to the current Aria transaction context but never properly deleted from it. Normally this isn't a problem, except if the mysql.proc table is closed before the transaction ended, which happened in this test case. Fixed by removing mysql.proc from the transaction context before closing the table.
-rw-r--r--mysql-test/suite/maria/system_tables.result13
-rw-r--r--mysql-test/suite/maria/system_tables.test27
-rw-r--r--sql/sql_base.cc7
3 files changed, 47 insertions, 0 deletions
diff --git a/mysql-test/suite/maria/system_tables.result b/mysql-test/suite/maria/system_tables.result
new file mode 100644
index 00000000000..32fddf6127e
--- /dev/null
+++ b/mysql-test/suite/maria/system_tables.result
@@ -0,0 +1,13 @@
+CREATE TABLE t1 (i INT) ENGINE=Aria;
+LOCK TABLE t1 WRITE;
+connect con1,localhost,root,,test;
+SET lock_wait_timeout= 2;
+FLUSH TABLES;
+connection default;
+CALL non_existing_sp;
+ERROR 42000: PROCEDURE test.non_existing_sp does not exist
+connection con1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+disconnect con1;
+connection default;
+DROP TABLE t1;
diff --git a/mysql-test/suite/maria/system_tables.test b/mysql-test/suite/maria/system_tables.test
new file mode 100644
index 00000000000..7b5c20ded85
--- /dev/null
+++ b/mysql-test/suite/maria/system_tables.test
@@ -0,0 +1,27 @@
+#
+# Test related to Aria system tables
+#
+
+#
+# MDEV-16986 Unitialized mutex, SIGSEGV and assorted assertion failures in
+# Aria code
+#
+
+CREATE TABLE t1 (i INT) ENGINE=Aria;
+LOCK TABLE t1 WRITE;
+
+--connect (con1,localhost,root,,test)
+SET lock_wait_timeout= 2;
+--send
+ FLUSH TABLES;
+--connection default
+--error ER_SP_DOES_NOT_EXIST
+CALL non_existing_sp;
+--connection con1
+--error ER_LOCK_WAIT_TIMEOUT
+--reap
+
+# Cleanup
+--disconnect con1
+--connection default
+DROP TABLE t1;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 4f1e149c291..7327484469a 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -8772,6 +8772,13 @@ open_system_tables_for_read(THD *thd, TABLE_LIST *table_list,
void
close_system_tables(THD *thd, Open_tables_backup *backup)
{
+ /*
+ Inform the transaction handler that we are closing the
+ system tables and we don't need the read view anymore.
+ */
+ for (TABLE *table= thd->open_tables ; table ; table= table->next)
+ table->file->extra(HA_EXTRA_PREPARE_FOR_FORCED_CLOSE);
+
close_thread_tables(thd);
thd->restore_backup_open_tables_state(backup);
}