summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2019-08-08 20:10:00 +0300
committerMonty <monty@mariadb.org>2019-08-08 23:08:23 +0300
commit6765cc607764c920bc5fbf4128bb526b73f15c2e (patch)
treeaf87f7f234df58df44e666fc5abd398113978fbb
parentdbac2039e81f6d371acdacfb65eba10e395bb9a2 (diff)
downloadmariadb-git-6765cc607764c920bc5fbf4128bb526b73f15c2e.tar.gz
Fixed assertion Assertion `!table->pos_in_locked_tables' failed
MDEV-17717 Assertion `!table->pos_in_locked_tables' failed in tc_release_table on flushing RocksDB table under SERIALIZABLE MDEV-17998 Deadlock and eventual Assertion `!table->pos_in_locked_tables' failed in tc_release_table on KILL_TIMEOUT MDEV-19591 Assertion `!table->pos_in_locked_tables' failed in tc_release_table upon altering table into S3 under lock. The problem was that thd->open_tables->pos_in_locked_tables was not reset when alter table failed to reopen a locked table.
-rw-r--r--mysql-test/r/kill.result17
-rw-r--r--mysql-test/t/kill.test21
-rw-r--r--sql/sql_base.cc1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/kill.result6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/kill.test9
5 files changed, 54 insertions, 0 deletions
diff --git a/mysql-test/r/kill.result b/mysql-test/r/kill.result
index dc1cb9252da..c2ad72e4240 100644
--- a/mysql-test/r/kill.result
+++ b/mysql-test/r/kill.result
@@ -399,3 +399,20 @@ DROP USER u1@localhost;
SET DEBUG_SYNC = 'RESET';
DROP FUNCTION MY_KILL;
set global sql_mode=default;
+#
+# MDEV-17998
+# Deadlock and eventual Assertion `!table->pos_in_locked_tables' failed
+# in tc_release_table on KILL_TIMEOUT
+#
+SET max_statement_time= 2;
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (b INT, c INT);
+LOCK TABLES v1 READ, t2 WRITE, t1 WRITE;
+ALTER TABLE t1 CHANGE f1 f2 DOUBLE;
+Got one of the listed errors
+ALTER TABLE t2 DROP c;
+ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
+UNLOCK TABLES;
+DROP VIEW v1;
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test
index b6000ffced1..a188cee52f2 100644
--- a/mysql-test/t/kill.test
+++ b/mysql-test/t/kill.test
@@ -642,3 +642,24 @@ SET DEBUG_SYNC = 'RESET';
DROP FUNCTION MY_KILL;
set global sql_mode=default;
+
+--echo #
+--echo # MDEV-17998
+--echo # Deadlock and eventual Assertion `!table->pos_in_locked_tables' failed
+--echo # in tc_release_table on KILL_TIMEOUT
+--echo #
+
+SET max_statement_time= 2;
+
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (b INT, c INT);
+
+LOCK TABLES v1 READ, t2 WRITE, t1 WRITE;
+--error ER_BAD_FIELD_ERROR,ER_STATEMENT_TIMEOUT
+ALTER TABLE t1 CHANGE f1 f2 DOUBLE;
+--error ER_STATEMENT_TIMEOUT
+ALTER TABLE t2 DROP c;
+UNLOCK TABLES;
+DROP VIEW v1;
+DROP TABLE t1, t2;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 25f3ed6e9ad..662ba3f6b30 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2371,6 +2371,7 @@ unlink_all_closed_tables(THD *thd, MYSQL_LOCK *lock, size_t reopen_count)
DBUG_ASSERT(thd->open_tables == m_reopen_array[reopen_count]);
thd->open_tables->pos_in_locked_tables->table= NULL;
+ thd->open_tables->pos_in_locked_tables= 0;
close_thread_table(thd, &thd->open_tables);
}
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/kill.result b/storage/rocksdb/mysql-test/rocksdb/r/kill.result
new file mode 100644
index 00000000000..19614e1fd95
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/kill.result
@@ -0,0 +1,6 @@
+CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=RocksDB;
+LOCK TABLE t1 WRITE;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+FLUSH TABLES;
+ERROR HY000: MyRocks supports only READ COMMITTED and REPEATABLE READ isolation levels. Please change from current isolation level SERIALIZABLE
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/kill.test b/storage/rocksdb/mysql-test/rocksdb/t/kill.test
new file mode 100644
index 00000000000..a2809d969d5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/kill.test
@@ -0,0 +1,9 @@
+--source include/have_binlog_format_row.inc
+--source include/have_rocksdb.inc
+
+CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=RocksDB;
+LOCK TABLE t1 WRITE;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+--error ER_ISOLATION_MODE_NOT_SUPPORTED
+FLUSH TABLES;
+DROP TABLE t1;