summaryrefslogtreecommitdiff
path: root/mysql-test/t/lock_multi.test
diff options
context:
space:
mode:
authorunknown <ingo@mysql.com>2006-05-29 15:26:23 +0200
committerunknown <ingo@mysql.com>2006-05-29 15:26:23 +0200
commit4f8407b6315736ab52b49e1e248e7585614c3f20 (patch)
tree59a370c72ba71b6114afc928164b485e2d1dd78c /mysql-test/t/lock_multi.test
parent0086d5abd9d59dc984d402e07a6df6f9c447f098 (diff)
downloadmariadb-git-4f8407b6315736ab52b49e1e248e7585614c3f20.tar.gz
Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock
The order of acquiring LOCK_mysql_create_db and wait_if_global_read_lock() was wrong. It could happen that a thread held LOCK_mysql_create_db while waiting for the global read lock to be released. The thread with the global read lock could try to administrate a database too. It would first try to lock LOCK_mysql_create_db and hang... The check if the current thread has the global read lock is done in wait_if_global_read_lock(), which could not be reached because of the hang in LOCK_mysql_create_db. Now I exchanged the order of acquiring LOCK_mysql_create_db and wait_if_global_read_lock(). This makes wait_if_global_read_lock() fail with an error message for the thread with the global read lock. No deadlock happens. mysql-test/r/lock_multi.result: Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock The test result mysql-test/t/lock_multi.test: Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock The test case sql/sql_db.cc: Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock Exchanged the order of acquiring LOCK_mysql_create_db and wait_if_global_read_lock().
Diffstat (limited to 'mysql-test/t/lock_multi.test')
-rw-r--r--mysql-test/t/lock_multi.test35
1 files changed, 35 insertions, 0 deletions
diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test
index 0d2266fc2ae..c7d2bcdfbc5 100644
--- a/mysql-test/t/lock_multi.test
+++ b/mysql-test/t/lock_multi.test
@@ -107,3 +107,38 @@ show columns from t1;
connection locker;
unlock tables;
drop table t1;
+
+#
+# Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock
+#
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+#
+connection con1;
+CREATE DATABASE mysqltest_1;
+FLUSH TABLES WITH READ LOCK;
+#
+# With bug in place: acquire LOCK_mysql_create_table and
+# wait in wait_if_global_read_lock().
+connection con2;
+send DROP DATABASE mysqltest_1;
+--sleep 1
+#
+# With bug in place: try to acquire LOCK_mysql_create_table...
+# When fixed: Reject dropping db because of the read lock.
+connection con1;
+--error ER_CANT_UPDATE_WITH_READLOCK
+DROP DATABASE mysqltest_1;
+UNLOCK TABLES;
+#
+connection con2;
+reap;
+#
+connection default;
+disconnect con1;
+disconnect con2;
+# This must have been dropped by connection 2 already,
+# which waited until the global read lock was released.
+--error ER_DB_DROP_EXISTS
+DROP DATABASE mysqltest_1;
+