summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2019-05-13 17:56:31 +0400
committerSergey Vojtovich <svoj@mariadb.org>2019-05-13 20:23:44 +0400
commit7a6c36b5474c61e5f2b4d86bac6d69a1dc0b2bf6 (patch)
treea8416ac59950fe1d9e5c1e4a22c12144e5721c40
parent341c3379ae4e86af54a1fb403529262076daad87 (diff)
downloadmariadb-git-7a6c36b5474c61e5f2b4d86bac6d69a1dc0b2bf6.tar.gz
Fixed main.flush_read_lock sporadic failure
With MDEV-19384 fixed FTWRL releases HANDLER locks early, which allows concurrent threads to go. Test case may get stuck on FTWRL waiting for LOCK TABLES.
-rw-r--r--mysql-test/main/flush_read_lock.result12
-rw-r--r--mysql-test/main/flush_read_lock.test19
-rw-r--r--sql/lock.cc1
3 files changed, 22 insertions, 10 deletions
diff --git a/mysql-test/main/flush_read_lock.result b/mysql-test/main/flush_read_lock.result
index f74937cb304..bd3b750f59e 100644
--- a/mysql-test/main/flush_read_lock.result
+++ b/mysql-test/main/flush_read_lock.result
@@ -1736,6 +1736,7 @@ SET DEBUG_SYNC= 'RESET';
# MDEV-19384 Deadlock between FTWRL under open HANDLER, LOCK TABLE
# and DROP DATABASE
#
+SET DEBUG_SYNC= 'ftwrl_before_lock SIGNAL ready WAIT_FOR go';
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.t1(a INT);
HANDLER mysqltest.t1 OPEN as t1;
@@ -1748,14 +1749,17 @@ SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL ready';
DROP DATABASE mysqltest;
connect con3,localhost,root,,;
SET DEBUG_SYNC= 'now WAIT_FOR ready';
-disconnect con3;
connection default;
FLUSH TABLES WITH READ LOCK;
-UNLOCK TABLES;
-HANDLER t1 CLOSE;
+connection con3;
+SET DEBUG_SYNC= 'now WAIT_FOR ready';
+disconnect con3;
connection con1;
-UNLOCK TABLES;
+SET DEBUG_SYNC= 'now SIGNAL go';
disconnect con1;
+connection default;
+UNLOCK TABLES;
+HANDLER t1 CLOSE;
connection con2;
disconnect con2;
connection default;
diff --git a/mysql-test/main/flush_read_lock.test b/mysql-test/main/flush_read_lock.test
index f537339ad6c..ab30cacada8 100644
--- a/mysql-test/main/flush_read_lock.test
+++ b/mysql-test/main/flush_read_lock.test
@@ -2100,6 +2100,7 @@ SET DEBUG_SYNC= 'RESET';
--echo # and DROP DATABASE
--echo #
+SET DEBUG_SYNC= 'ftwrl_before_lock SIGNAL ready WAIT_FOR go';
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.t1(a INT);
HANDLER mysqltest.t1 OPEN as t1;
@@ -2114,18 +2115,24 @@ SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL ready';
connect (con3,localhost,root,,);
SET DEBUG_SYNC= 'now WAIT_FOR ready';
-disconnect con3;
connection default;
-FLUSH TABLES WITH READ LOCK;
-UNLOCK TABLES;
-HANDLER t1 CLOSE;
-connection con1;
+send FLUSH TABLES WITH READ LOCK;
+
+connection con3;
+SET DEBUG_SYNC= 'now WAIT_FOR ready';
+disconnect con3;
+connection con1;
--error 0,ER_NO_SUCH_TABLE
reap;
-UNLOCK TABLES;
+SET DEBUG_SYNC= 'now SIGNAL go';
disconnect con1;
+
+connection default;
+reap;
+UNLOCK TABLES;
+HANDLER t1 CLOSE;
connection con2;
reap;
disconnect con2;
diff --git a/sql/lock.cc b/sql/lock.cc
index 596e77b23e3..01e0f418179 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -1034,6 +1034,7 @@ bool Global_read_lock::lock_global_read_lock(THD *thd)
if another thread is trying to simultaneous drop the table
*/
mysql_ha_cleanup_no_free(thd);
+ DEBUG_SYNC(thd, "ftwrl_before_lock");
DBUG_ASSERT(! thd->mdl_context.is_lock_owner(MDL_key::BACKUP, "", "",
MDL_BACKUP_FTWRL1));