From 38ecd541e887bef151860030a0c1978393d932a2 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 20 Aug 2018 17:50:34 +0300 Subject: 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. --- mysql-test/suite/maria/system_tables.result | 13 +++++++++++++ mysql-test/suite/maria/system_tables.test | 27 +++++++++++++++++++++++++++ sql/sql_base.cc | 7 +++++++ 3 files changed, 47 insertions(+) create mode 100644 mysql-test/suite/maria/system_tables.result create mode 100644 mysql-test/suite/maria/system_tables.test 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); } -- cgit v1.2.1