Skip to content

Commit

Permalink
Record BACKUP and SCHEMA namespaces order
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Vojtovich committed Jun 6, 2019
1 parent 965db35 commit 6999da9
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mysql-test/main/backup_lock_debug.result
Original file line number Diff line number Diff line change
Expand Up @@ -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';
38 changes: 38 additions & 0 deletions mysql-test/main/backup_lock_debug.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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';

0 comments on commit 6999da9

Please sign in to comment.