summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2019-06-06 14:41:45 +0400
committerSergey Vojtovich <svoj@mariadb.org>2019-06-06 14:41:45 +0400
commit6999da9b19c3c325a37016d2c3f35323dc1599a6 (patch)
tree88004dd7525e5879090912dc78e2d6ba5025d883
parent965db355e63e3123423d6f8cdedbe2c653bf1480 (diff)
downloadmariadb-git-6999da9b19c3c325a37016d2c3f35323dc1599a6.tar.gz
Record BACKUP and SCHEMA namespaces order
-rw-r--r--mysql-test/main/backup_lock_debug.result25
-rw-r--r--mysql-test/main/backup_lock_debug.test38
2 files changed, 63 insertions, 0 deletions
diff --git a/mysql-test/main/backup_lock_debug.result b/mysql-test/main/backup_lock_debug.result
index 8832d9cd3e7..7c7b05901a9 100644
--- a/mysql-test/main/backup_lock_debug.result
+++ b/mysql-test/main/backup_lock_debug.result
@@ -26,3 +26,28 @@ disconnect con1;
connection default;
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
+#
+# Demonstrates a deadlock if BACKUP namespace is reorder after SCHEMA.
+# Culprit is ALTER TABLE taking SCHEMA lock on target database after
+# BACKUP lock was acquired.
+#
+CREATE DATABASE test2;
+CREATE TABLE t1(a INT) ENGINE=InnoDB;
+SET DEBUG_SYNC='alter_opened_table SIGNAL ready WAIT_FOR go';
+ALTER TABLE t1 RENAME TO test2.t1;
+connect con1,localhost,root,,;
+SET DEBUG_SYNC='now WAIT_FOR ready';
+BACKUP STAGE START;
+SET DEBUG_SYNC='mdl_acquire_lock_wait SIGNAL ready1';
+BACKUP STAGE BLOCK_DDL;
+connect con2,localhost,root,,;
+SET DEBUG_SYNC='now WAIT_FOR ready1';
+SET DEBUG_SYNC='mdl_acquire_lock_wait SIGNAL go';
+DROP DATABASE test2;
+connection default;
+connection con1;
+disconnect con1;
+connection con2;
+disconnect con2;
+connection default;
+SET DEBUG_SYNC='reset';
diff --git a/mysql-test/main/backup_lock_debug.test b/mysql-test/main/backup_lock_debug.test
index 8cf492b3404..80e7cf9e181 100644
--- a/mysql-test/main/backup_lock_debug.test
+++ b/mysql-test/main/backup_lock_debug.test
@@ -3,6 +3,7 @@
########################################################################
--source include/have_debug_sync.inc
+--source include/have_innodb.inc
--echo #
--echo # Make sure pending LOCK TABLES doesn't block BACKUP STAGE
@@ -38,3 +39,40 @@ disconnect con1;
connection default;
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
+
+
+--echo #
+--echo # Demonstrates a deadlock if BACKUP namespace is reorder after SCHEMA.
+--echo # Culprit is ALTER TABLE taking SCHEMA lock on target database after
+--echo # BACKUP lock was acquired.
+--echo #
+CREATE DATABASE test2;
+CREATE TABLE t1(a INT) ENGINE=InnoDB;
+
+SET DEBUG_SYNC='alter_opened_table SIGNAL ready WAIT_FOR go';
+send ALTER TABLE t1 RENAME TO test2.t1;
+
+connect (con1,localhost,root,,);
+SET DEBUG_SYNC='now WAIT_FOR ready';
+BACKUP STAGE START;
+SET DEBUG_SYNC='mdl_acquire_lock_wait SIGNAL ready1';
+send BACKUP STAGE BLOCK_DDL;
+
+connect (con2,localhost,root,,);
+SET DEBUG_SYNC='now WAIT_FOR ready1';
+SET DEBUG_SYNC='mdl_acquire_lock_wait SIGNAL go';
+send DROP DATABASE test2;
+
+connection default;
+reap;
+
+connection con1;
+reap;
+disconnect con1;
+
+connection con2;
+reap;
+disconnect con2;
+
+connection default;
+SET DEBUG_SYNC='reset';