diff options
Diffstat (limited to 'mysql-test/t/mdl_sync.test')
-rw-r--r-- | mysql-test/t/mdl_sync.test | 731 |
1 files changed, 0 insertions, 731 deletions
diff --git a/mysql-test/t/mdl_sync.test b/mysql-test/t/mdl_sync.test index 8e809788a08..4aa191d3dfc 100644 --- a/mysql-test/t/mdl_sync.test +++ b/mysql-test/t/mdl_sync.test @@ -101,7 +101,6 @@ create table t1 (c1 int); --echo # handler t1 open; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that S, SH, SR and SW locks are compatible with it. handler t1 open t; @@ -120,15 +119,10 @@ alter table t1 add index (not_exist); --echo # lock. --error ER_DUP_ENTRY alter table t1 add primary key (c1); ---echo # Check that SNRW lock is compatible with S lock. -lock table t1 write; -insert into t1 values (1); -unlock tables; --echo # Check that X lock is incompatible with S lock. --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above RENAME is blocked because of S lock. let $wait_condition= @@ -137,29 +131,24 @@ let $wait_condition= info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # ---echo # Switching to connection 'default'. connection default; --echo # Unblock RENAME TABLE. handler t1 close; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping RENAME TABLE. --reap --echo # Restore the original state of the things. rename table t2 to t1; --echo # ---echo # Switching to connection 'default'. connection default; handler t1 open; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that upgrade from SNW to X is blocked by presence of S lock. --echo # Sending: --send alter table t1 add column c2 int; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above ALTER TABLE is blocked because of S lock. let $wait_condition= @@ -168,53 +157,16 @@ let $wait_condition= info = "alter table t1 add column c2 int"; --source include/wait_condition.inc --echo # ---echo # Switching to connection 'default'. connection default; --echo # Unblock ALTER TABLE. handler t1 close; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping ALTER TABLE. --reap --echo # Restore the original state of the things. alter table t1 drop column c2; --echo # ---echo # Switching to connection 'default'. -connection default; -handler t1 open; ---echo # ---echo # Switching to connection 'mdl_con1'. -connection mdl_con1; ---echo # Check that upgrade from SNRW to X is blocked by presence of S lock. -lock table t1 write; ---echo # Sending: ---send alter table t1 add column c2 int; ---echo # ---echo # Switching to connection 'mdl_con2'. -connection mdl_con2; ---echo # Check that the above upgrade of SNRW to X in ALTER TABLE is blocked ---echo # because of S lock. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table metadata lock" and - info = "alter table t1 add column c2 int"; ---source include/wait_condition.inc ---echo # ---echo # Switching to connection 'default'. -connection default; ---echo # Unblock ALTER TABLE. -handler t1 close; ---echo # ---echo # Switching to connection 'mdl_con1'. -connection mdl_con1; ---echo # Reaping ALTER TABLE. ---reap ---echo # Restore the original state of the things. -alter table t1 drop column c2; -unlock tables; ---echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # 2) Acquire SH (shared high-priority) lock on the table. @@ -225,7 +177,6 @@ set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish'; --echo # Sending: --send select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t1'; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; set debug_sync= 'now WAIT_FOR locked'; --echo # Check that S, SH, SR and SW locks are compatible with it. @@ -253,7 +204,6 @@ unlock tables; --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above RENAME is blocked because of SH lock. let $wait_condition= @@ -264,32 +214,27 @@ let $wait_condition= --echo # Unblock RENAME TABLE. set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping SELECT ... FROM I_S. --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping RENAME TABLE. --reap --echo # Restore the original state of the things. rename table t2 to t1; --echo # ---echo # Switching to connection 'default'. connection default; set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish'; --echo # Sending: --send select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t1'; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; set debug_sync= 'now WAIT_FOR locked'; --echo # Check that upgrade from SNW to X is blocked by presence of SH lock. --echo # Sending: --send alter table t1 add column c2 int; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above ALTER TABLE is blocked because of SH lock. let $wait_condition= @@ -300,24 +245,20 @@ let $wait_condition= --echo # Unblock RENAME TABLE. set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping SELECT ... FROM I_S. --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping ALTER TABLE. --reap --echo # Restore the original state of the things. alter table t1 drop column c2; --echo # ---echo # Switching to connection 'default'. connection default; set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish'; --send select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t1'; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; set debug_sync= 'now WAIT_FOR locked'; --echo # Check that upgrade from SNRW to X is blocked by presence of S lock. @@ -325,7 +266,6 @@ lock table t1 write; --echo # Sending: --send alter table t1 add column c2 int; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above upgrade of SNRW to X in ALTER TABLE is blocked --echo # because of S lock. @@ -337,12 +277,10 @@ let $wait_condition= --echo # Unblock RENAME TABLE. set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping SELECT ... FROM I_S. --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping ALTER TABLE. --reap @@ -350,7 +288,6 @@ connection mdl_con1; alter table t1 drop column c2; unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # @@ -360,7 +297,6 @@ connection default; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that S, SH, SR and SW locks are compatible with it. handler t1 open; @@ -383,7 +319,6 @@ alter table t1 add primary key (c1); --echo # Sending: --send lock table t1 write; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Check that the above LOCK TABLES is blocked because of SR lock. let $wait_condition= @@ -394,25 +329,21 @@ let $wait_condition= --echo # Unblock LOCK TABLES. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping LOCK TABLES. --reap delete from t1 limit 1; unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that X lock is incompatible with SR lock. --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above RENAME is blocked because of SR lock. let $wait_condition= @@ -421,30 +352,25 @@ let $wait_condition= info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # ---echo # Switching to connection 'default'. connection default; --echo # Unblock RENAME TABLE. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping RENAME TABLE. --reap --echo # Restore the original state of the things. rename table t2 to t1; --echo # ---echo # Switching to connection 'default'. connection default; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that upgrade from SNW to X is blocked by presence of SR lock. --echo # Sending: --send alter table t1 add column c2 int; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above ALTER TABLE is blocked because of SR lock. let $wait_condition= @@ -453,12 +379,10 @@ let $wait_condition= info = "alter table t1 add column c2 int"; --source include/wait_condition.inc --echo # ---echo # Switching to connection 'default'. connection default; --echo # Unblock ALTER TABLE. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping ALTER TABLE. --reap @@ -469,7 +393,6 @@ alter table t1 drop column c2; --echo # by presence of SR lock because SNRW is incompatible with SR anyway. --echo # --echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # @@ -479,7 +402,6 @@ connection default; begin; insert into t1 values (1); --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that S, SH, SR and SW locks are compatible with it. handler t1 open; @@ -503,7 +425,6 @@ alter table t1 add index (not_exist); --echo # Sending: --send alter table t1 add primary key (c1); --echo # ---echo # Switching to connection 'default'. connection default; --echo # Check that the above ALTER TABLE is blocked because of SW lock. let $wait_condition= @@ -514,24 +435,20 @@ let $wait_condition= --echo # Unblock ALTER TABLE. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping ALTER TABLE. --error ER_DUP_ENTRY --reap --echo # ---echo # Switching to connection 'default'. connection default; begin; insert into t1 values (1); --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that SNRW lock is not compatible with SW lock. --echo # Sending: --send lock table t1 write; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Check that the above LOCK TABLES is blocked because of SW lock. let $wait_condition= @@ -542,25 +459,21 @@ let $wait_condition= --echo # Unblock LOCK TABLES. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping LOCK TABLES. --reap delete from t1 limit 2; unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; begin; insert into t1 values (1); --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that X lock is incompatible with SW lock. --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above RENAME is blocked because of SW lock. let $wait_condition= @@ -569,12 +482,10 @@ let $wait_condition= info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # ---echo # Switching to connection 'default'. connection default; --echo # Unblock RENAME TABLE. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping RENAME TABLE. --reap @@ -586,7 +497,6 @@ rename table t2 to t1; --echo # with SW anyway. --echo # --echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # @@ -597,7 +507,6 @@ set debug_sync= 'alter_opened_table SIGNAL locked WAIT_FOR finish'; --echo # Sending: --send alter table t1 add primary key (c1); --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; set debug_sync= 'now WAIT_FOR locked'; --echo # Check that S, SH, SR and SW locks are compatible with it. @@ -611,7 +520,6 @@ delete from t1 limit 1; --echo # Sending: --send alter table t1 add primary key (c1); --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above ALTER is blocked because of SU lock. let $wait_condition= @@ -622,32 +530,27 @@ let $wait_condition= --echo # Unblock ALTERs. set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping first ALTER TABLE. --error ER_DUP_ENTRY --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping another ALTER TABLE. --error ER_DUP_ENTRY --reap --echo # ---echo # Switching to connection 'default'. connection default; set debug_sync= 'alter_opened_table SIGNAL locked WAIT_FOR finish'; --echo # Sending: --send alter table t1 add primary key (c1); --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; set debug_sync= 'now WAIT_FOR locked'; --echo # Check that SNRW lock is incompatible with SU lock. --echo # Sending: --send lock table t1 write; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above LOCK TABLES is blocked because of SU lock. let $wait_condition= @@ -658,33 +561,28 @@ let $wait_condition= --echo # Unblock ALTER and thus LOCK TABLES. set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping ALTER TABLE. --error ER_DUP_ENTRY --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping LOCK TABLES --reap insert into t1 values (1); unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; set debug_sync= 'alter_opened_table SIGNAL locked WAIT_FOR finish'; --echo # Sending: --send alter table t1 add primary key (c1); --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; set debug_sync= 'now WAIT_FOR locked'; --echo # Check that X lock is incompatible with SU lock. --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above RENAME is blocked because of SU lock. let $wait_condition= @@ -695,7 +593,6 @@ let $wait_condition= --echo # Unblock ALTER and thus RENAME TABLE. set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Now we have ALTER TABLE with SU->SNW and RENAME TABLE with pending --echo # X-lock. In this case ALTER TABLE should be chosen as victim. @@ -703,7 +600,6 @@ connection default; --error ER_LOCK_DEADLOCK --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping RENAME TABLE --reap @@ -714,7 +610,6 @@ rename table t2 to t1; --echo # blocked by presence of another SU lock because SNW/SNRW is --echo # incompatible with SU anyway. --echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # @@ -725,7 +620,6 @@ set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL locked WAIT_FOR fini --echo # Sending: --send alter table t1 add primary key (c1), lock=shared, algorithm=copy; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; set debug_sync= 'now WAIT_FOR locked'; --echo # Check that S, SH and SR locks are compatible with it. @@ -738,7 +632,6 @@ select count(*) from t1; --echo # Sending: --send delete from t1 limit 2; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above DELETE is blocked because of SNW lock. let $wait_condition= @@ -749,31 +642,26 @@ let $wait_condition= --echo # Unblock ALTER and thus DELETE. set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping ALTER TABLE. --error ER_DUP_ENTRY --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping DELETE. --reap --echo # ---echo # Switching to connection 'default'. connection default; set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL locked WAIT_FOR finish'; --echo # Sending: --send alter table t1 add primary key (c1), lock=shared, algorithm=copy; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; set debug_sync= 'now WAIT_FOR locked'; --echo # Check that SU lock is incompatible with SNW lock. --echo # Sending: --send alter table t1 add primary key (c1); --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above ALTER is blocked because of SNW lock. let $wait_condition= @@ -784,13 +672,11 @@ let $wait_condition= --echo # Unblock ALTERs. set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping first ALTER TABLE. --error ER_DUP_ENTRY --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping another ALTER TABLE. --error ER_DUP_ENTRY @@ -800,20 +686,17 @@ connection mdl_con1; --echo # SNW is only used by ALTER TABLE after upgrading from SU --echo # and SU is also incompatible with SNW. --echo # ---echo # Switching to connection 'default'. connection default; set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL locked WAIT_FOR finish'; --echo # Sending: --send alter table t1 add primary key (c1), lock=shared, algorithm=copy; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; set debug_sync= 'now WAIT_FOR locked'; --echo # Check that SNRW lock is incompatible with SNW lock. --echo # Sending: --send lock table t1 write; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above LOCK TABLES is blocked because of SNW lock. let $wait_condition= @@ -824,33 +707,28 @@ let $wait_condition= --echo # Unblock ALTER and thus LOCK TABLES. set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping ALTER TABLE. --error ER_DUP_ENTRY --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping LOCK TABLES --reap insert into t1 values (1); unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL locked WAIT_FOR finish'; --echo # Sending: --send alter table t1 add primary key (c1), algorithm=copy, lock=shared; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; set debug_sync= 'now WAIT_FOR locked'; --echo # Check that X lock is incompatible with SNW lock. --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above RENAME is blocked because of SNW lock. let $wait_condition= @@ -861,13 +739,11 @@ let $wait_condition= --echo # Unblock ALTER and thus RENAME TABLE. set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping ALTER TABLE. --error ER_DUP_ENTRY --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping RENAME TABLE --reap @@ -878,7 +754,6 @@ rename table t2 to t1; --echo # blocked by presence of another SNW lock because SNW/SNRW is --echo # incompatible with SNW anyway. --echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # @@ -887,18 +762,14 @@ connection default; --echo # lock table t1 write; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that S and SH locks are compatible with it. -handler t1 open; -handler t1 close; select column_name from information_schema.columns where table_schema='test' and table_name='t1'; --echo # Check that SR lock is incompatible with SNRW lock. --echo # Sending: --send select count(*) from t1; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Check that the above SELECT is blocked because of SNRW lock. let $wait_condition= @@ -909,22 +780,18 @@ let $wait_condition= --echo # Unblock SELECT. unlock tables; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping SELECT. --reap --echo # ---echo # Switching to connection 'default'. connection default; lock table t1 write; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that SW lock is incompatible with SNRW lock. --echo # Sending: --send delete from t1 limit 1; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Check that the above DELETE is blocked because of SNRW lock. let $wait_condition= @@ -935,22 +802,18 @@ let $wait_condition= --echo # Unblock DELETE. unlock tables; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping DELETE. --reap --echo # ---echo # Switching to connection 'default'. connection default; lock table t1 write; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that SU lock is incompatible with SNRW lock. --echo # Sending: --send alter table t1 add primary key (c1); --echo # ---echo # Switching to connection 'default'. connection default; --echo # Check that the above ALTER is blocked because of SNRW lock. let $wait_condition= @@ -961,7 +824,6 @@ let $wait_condition= --echo # Unblock ALTER. unlock tables; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping ALTER TABLE. --error ER_DUP_ENTRY @@ -971,17 +833,14 @@ connection mdl_con1; --echo # SNW is only used by ALTER TABLE after upgrading from SU --echo # and SU is also incompatible with SNRW. --echo # ---echo # Switching to connection 'default'. connection default; lock table t1 write; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that SNRW lock is incompatible with SNRW lock. --echo # Sending: --send lock table t1 write; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Check that the above LOCK TABLES is blocked because of SNRW lock. let $wait_condition= @@ -992,24 +851,20 @@ let $wait_condition= --echo # Unblock waiting LOCK TABLES. unlock tables; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping LOCK TABLES --reap insert into t1 values (1); unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; lock table t1 write; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that X lock is incompatible with SNRW lock. --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Check that the above RENAME is blocked because of SNRW lock. let $wait_condition= @@ -1020,7 +875,6 @@ let $wait_condition= --echo # Unblock RENAME TABLE unlock tables; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping RENAME TABLE --reap @@ -1031,7 +885,6 @@ rename table t2 to t1; --echo # blocked by presence of another SNRW lock because SNW/SNRW is --echo # incompatible with SNRW anyway. --echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # @@ -1040,18 +893,15 @@ connection default; --echo # create table t2 (c1 int); --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Take a lock on t2, so RENAME TABLE t1 TO t2 will get blocked --echo # after acquiring X lock on t1. lock tables t2 read; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= @@ -1063,7 +913,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send handler t1 open; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above HANDLER statement is blocked because of X lock. let $wait_condition= @@ -1074,29 +923,24 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping RENAME TABLE. --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping HANDLER. --reap handler t1 close; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Prepare for blocking RENAME TABLE. lock tables t2 read; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= @@ -1108,7 +952,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send select column_name from information_schema.columns where table_schema='test' and table_name='t1'; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above SELECT ... FROM I_S ... statement is blocked --echo # because of X lock. @@ -1120,28 +963,23 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping RENAME TABLE. --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping SELECT ... FROM I_S. --reap --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Prepare for blocking RENAME TABLE. lock tables t2 read; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= @@ -1153,7 +991,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above SELECT statement is blocked --echo # because of X lock. @@ -1165,28 +1002,23 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping RENAME TABLE. --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping SELECT. --reap --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Prepare for blocking RENAME TABLE. lock tables t2 read; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= @@ -1198,7 +1030,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send delete from t1 limit 1; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above DELETE statement is blocked --echo # because of X lock. @@ -1210,28 +1041,23 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping RENAME TABLE. --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping DELETE. --reap --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Prepare for blocking RENAME TABLE. lock tables t2 read; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= @@ -1243,7 +1069,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send alter table t1 add primary key (c1); --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above ALTER statement is blocked --echo # because of X lock. @@ -1255,13 +1080,11 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping RENAME TABLE --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping ALTER. --error ER_DUP_ENTRY @@ -1271,17 +1094,14 @@ connection mdl_con1; --echo # SNW is only used by ALTER TABLE after upgrading from SU --echo # and SU is also incompatible with X. --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Prepare for blocking RENAME TABLE. lock tables t2 read; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= @@ -1293,7 +1113,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send lock table t1 write; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above LOCK TABLE statement is blocked --echo # because of X lock. @@ -1305,29 +1124,24 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping RENAME TABLE --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping LOCK TABLE. --reap unlock tables; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Prepare for blocking RENAME TABLE. lock tables t2 read; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= @@ -1339,7 +1153,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send rename table t1 to t3; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above RENAME statement is blocked --echo # because of X lock. @@ -1351,13 +1164,11 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping RENAME TABLE --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping RENAME. --reap @@ -1373,7 +1184,6 @@ rename table t3 to t1; --echo # --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # --echo # 1) Check compatibility for pending SNW lock. @@ -1382,13 +1192,11 @@ connection mdl_con2; begin; insert into t1 values (1); --echo # ---echo # Switching to connection 'default'. connection default; --echo # Add pending SNW lock. --echo # Sending: --send alter table t1 add primary key (c1); --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that ALTER TABLE is waiting with pending SNW lock. let $wait_condition= @@ -1406,7 +1214,6 @@ select count(*) from t1; --echo # Sending: --send delete from t1 limit 1; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above DELETE is blocked because of pending SNW lock. let $wait_condition= @@ -1417,13 +1224,11 @@ where state = "Waiting for table metadata lock" and --echo # Unblock ALTER TABLE. commit; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping ALTER. --error ER_DUP_ENTRY --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping DELETE. --reap @@ -1432,7 +1237,6 @@ connection mdl_con1; --echo # they will also be blocked by active SW lock. --echo # --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # --echo # 2) Check compatibility for pending SNRW lock. @@ -1441,13 +1245,11 @@ connection mdl_con2; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Add pending SNRW lock. --echo # Sending: --send lock table t1 write; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that LOCK TABLE is waiting with pending SNRW lock. let $wait_condition= @@ -1456,15 +1258,12 @@ where state = "Waiting for table metadata lock" and info = "lock table t1 write"; --source include/wait_condition.inc --echo # Check that S and SH locks are compatible with pending SNRW -handler t1 open t; -handler t close; select column_name from information_schema.columns where table_schema='test' and table_name='t1'; --echo # Check that SR is incompatible with pending SNRW --echo # Sending: --send select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above SELECT is blocked because of pending SNRW lock. let $wait_condition= @@ -1475,29 +1274,24 @@ where state = "Waiting for table metadata lock" and --echo # Unblock LOCK TABLE. commit; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping LOCK TABLE. --reap unlock tables; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping SELECT. --reap --echo # Restore pending SNRW lock. --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Sending: --send lock table t1 write; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that LOCK TABLE is waiting with pending SNRW lock. let $wait_condition= @@ -1509,7 +1303,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send insert into t1 values (1); --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above INSERT is blocked because of pending SNRW lock. let $wait_condition= @@ -1520,29 +1313,24 @@ where state = "Waiting for table metadata lock" and --echo # Unblock LOCK TABLE. commit; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping LOCK TABLE. --reap unlock tables; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping INSERT. --reap --echo # Restore pending SNRW lock. --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Sending: --send lock table t1 write; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that LOCK TABLE is waiting with pending SNRW lock. let $wait_condition= @@ -1555,12 +1343,10 @@ where state = "Waiting for table metadata lock" and --error ER_DUP_ENTRY alter table t1 add primary key (c1); --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Unblock LOCK TABLE. commit; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping LOCK TABLE. --reap @@ -1570,7 +1356,6 @@ unlock tables; --echo # they will also be blocked by active SR lock. --echo # --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # --echo # 3) Check compatibility for pending X lock. @@ -1579,13 +1364,11 @@ connection mdl_con2; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Add pending X lock. --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that RENAME TABLE is waiting with pending X lock. let $wait_condition= @@ -1600,7 +1383,6 @@ select column_name from information_schema.columns where --echo # Sending: --send handler t1 open; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above HANDLER OPEN is blocked because of pending X lock. let $wait_condition= @@ -1611,31 +1393,26 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE. commit; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping RENAME TABLE. --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping HANDLER t1 OPEN. --reap handler t1 close; --echo # Restore pending X lock. --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Add pending X lock. --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that RENAME TABLE is waiting with pending X lock. let $wait_condition= @@ -1647,7 +1424,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above SELECT is blocked because of pending X lock. let $wait_condition= @@ -1658,30 +1434,25 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE. commit; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping RENAME TABLE. --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping SELECT. --reap --echo # Restore pending X lock. --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Add pending X lock. --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that RENAME TABLE is waiting with pending X lock. let $wait_condition= @@ -1693,7 +1464,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send delete from t1 limit 1; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above DELETE is blocked because of pending X lock. let $wait_condition= @@ -1704,30 +1474,25 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE. commit; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping RENAME TABLE. --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping DELETE. --reap --echo # Restore pending X lock. --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Add pending X lock. --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that RENAME TABLE is waiting with pending X lock. let $wait_condition= @@ -1739,7 +1504,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send alter table t1 add primary key (c1); --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above ALTER TABLE is blocked because of pending X lock. let $wait_condition= @@ -1750,30 +1514,25 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE. commit; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping RENAME TABLE. --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping ALTER TABLE. --error ER_DUP_ENTRY --reap --echo # Restore pending X lock. --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; handler t1 open; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Add pending X lock. --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that RENAME TABLE is waiting with pending X lock. let $wait_condition= @@ -1785,7 +1544,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send lock table t1 write; --echo # ---echo # Switching to connection 'mdl_con3'. connection mdl_con3; --echo # Check that the above LOCK TABLES is blocked because of pending X lock. let $wait_condition= @@ -1794,24 +1552,20 @@ where state = "Waiting for table metadata lock" and info = "lock table t1 write"; --source include/wait_condition.inc --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Unblock RENAME TABLE. handler t1 close; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping RENAME TABLE. --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reaping LOCK TABLES. --reap unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # @@ -1833,7 +1587,6 @@ connection default; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Create an active SNW lock on t2. --echo # We have to use DEBUG_SYNC facility as otherwise SNW lock @@ -1843,7 +1596,6 @@ set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL locked WAIT_FOR fini --echo # Sending: --send alter table t2 add primary key (c1), algorithm=copy, lock=shared; --echo # ---echo # Switching to connection 'default'. connection default; set debug_sync= 'now WAIT_FOR locked'; --echo # SR lock should be acquired without any waiting. @@ -1855,7 +1607,6 @@ select count(*) from t1; --echo # Sending: --send insert into t2 values (1); --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above INSERT is blocked. let $wait_condition= @@ -1866,13 +1617,11 @@ where state = "Waiting for table metadata lock" and --echo # Unblock ALTER TABLE and thus INSERT. set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reap ALTER TABLE. --error ER_DUP_ENTRY --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap INSERT. --reap @@ -1887,14 +1636,12 @@ commit; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Create an active SNW lock on t1. set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL locked WAIT_FOR finish'; --echo # Sending: --send alter table t1 add primary key (c1), algorithm=copy, lock=shared; --echo # ---echo # Switching to connection 'default'. connection default; set debug_sync= 'now WAIT_FOR locked'; --echo # We should still be able to get SR lock without waiting. @@ -1905,7 +1652,6 @@ select count(*) from t1; --echo # Sending: --send insert into t1 values (1); --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above INSERT is blocked. let $wait_condition= @@ -1916,13 +1662,11 @@ where state = "Waiting for table metadata lock" and --echo # Unblock ALTER TABLE and thus INSERT. set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reap ALTER TABLE. --error ER_DUP_ENTRY --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap INSERT. --reap @@ -1935,13 +1679,11 @@ commit; begin; insert into t1 values (1); --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Create pending SNW lock on t1. --echo # Sending: --send alter table t1 add primary key (c1); --echo # ---echo # Switching to connection 'default'. connection default; --echo # Wait until ALTER TABLE starts waiting for SNW lock. let $wait_condition= @@ -1955,13 +1697,11 @@ delete from t1 limit 1; --echo # Unblock ALTER TABLE. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reap ALTER TABLE. --error ER_DUP_ENTRY --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # 2) Now similar tests for active SNW lock which is being upgraded @@ -1972,20 +1712,17 @@ connection default; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Start transaction which will prevent SNW -> X upgrade from --echo # completing immediately. begin; select count(*) from t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Create SNW lock pending upgrade to X on t2. --echo # Sending: --send alter table t2 add column c2 int; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Wait until ALTER TABLE starts waiting X lock. let $wait_condition= @@ -1997,7 +1734,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send select count(*) from t2; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above SELECT is blocked. let $wait_condition= @@ -2008,12 +1744,10 @@ where state = "Waiting for table metadata lock" and --echo # Unblock ALTER TABLE. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reap ALTER TABLE. --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap SELECT. --reap @@ -2022,20 +1756,17 @@ commit; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Start transaction which will prevent SNW -> X upgrade from --echo # completing immediately. begin; select count(*) from t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Create SNW lock pending upgrade to X on t2. --echo # Sending: --send alter table t2 drop column c2; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Wait until ALTER TABLE starts waiting X lock. let $wait_condition= @@ -2047,7 +1778,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send insert into t2 values (1); --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above INSERT is blocked. let $wait_condition= @@ -2058,12 +1788,10 @@ where state = "Waiting for table metadata lock" and --echo # Unblock ALTER TABLE. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reap ALTER TABLE. --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap INSERT. --reap @@ -2075,13 +1803,11 @@ commit; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Create SNW lock pending upgrade to X. --echo # Sending: --send alter table t1 add column c2 int; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Wait until ALTER TABLE starts waiting X lock. let $wait_condition= @@ -2098,12 +1824,10 @@ delete from t1 limit 1; --echo # Unblock ALTER TABLE. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reap ALTER TABLE. --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # 3) Check how various locks used within transactional context @@ -2114,18 +1838,15 @@ connection default; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; lock table t2 write; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Attempt to acquire SR should be blocked. It should --echo # not cause errors as it does not creates deadlock. --echo # Sending: --send select count(*) from t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that the above SELECT is blocked let $wait_condition= @@ -2136,7 +1857,6 @@ where state = "Waiting for table metadata lock" and --echo # Unblock SELECT. unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap SELECT. --reap @@ -2145,18 +1865,15 @@ commit; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; lock table t2 write; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Again attempt to acquire SW should be blocked and should --echo # not cause any errors. --echo # Sending: --send delete from t2 limit 1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Check that the above DELETE is blocked let $wait_condition= @@ -2167,7 +1884,6 @@ where state = "Waiting for table metadata lock" and --echo # Unblock DELETE. unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap DELETE. --reap @@ -2182,12 +1898,10 @@ commit; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Sending: --send lock table t1 write; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Wait until LOCK TABLE is blocked creating pending request for X lock. let $wait_condition= @@ -2204,13 +1918,11 @@ delete from t1 limit 1; --echo # Unblock LOCK TABLES. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reap LOCK TABLES. --reap unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # **) Now case when transaction has a SW lock. @@ -2218,12 +1930,10 @@ connection default; begin; delete from t1 limit 1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Sending: --send lock table t1 write; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Wait until LOCK TABLE is blocked creating pending request for X lock. let $wait_condition= @@ -2238,13 +1948,11 @@ insert into t1 values (1, 1); --echo # Unblock LOCK TABLES. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reap LOCK TABLES. --reap unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # 4) Check how various locks used within transactional context @@ -2255,20 +1963,17 @@ connection default; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Start transaction which will prevent X lock from going away --echo # immediately. begin; select count(*) from t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Create pending X lock on t2. --echo # Sending: --send rename table t2 to t3; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Wait until RENAME TABLE starts waiting with pending X lock. let $wait_condition= @@ -2280,7 +1985,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send select count(*) from t2; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above SELECT is blocked. let $wait_condition= @@ -2291,12 +1995,10 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reap RENAME TABLE. --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap SELECT. --error ER_NO_SUCH_TABLE @@ -2307,20 +2009,17 @@ rename table t3 to t2; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Start transaction which will prevent X lock from going away --echo # immediately. begin; select count(*) from t2; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Create pending X lock on t2. --echo # Sending: --send rename table t2 to t3; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Wait until RENAME TABLE starts waiting with pending X lock. let $wait_condition= @@ -2332,7 +2031,6 @@ where state = "Waiting for table metadata lock" and --echo # Sending: --send delete from t2 limit 1; --echo # ---echo # Switching to connection 'mdl_con2'. connection mdl_con2; --echo # Check that the above DELETE is blocked. let $wait_condition= @@ -2343,12 +2041,10 @@ where state = "Waiting for table metadata lock" and --echo # Unblock RENAME TABLE. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reap RENAME TABLE. --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap DELETE. --error ER_NO_SUCH_TABLE @@ -2365,12 +2061,10 @@ rename table t3 to t2; begin; select count(*) from t1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Wait until RENAME TABLE is blocked creating pending request for X lock. let $wait_condition= @@ -2387,13 +2081,11 @@ delete from t1 limit 1; --echo # Unblock RENAME TABLE. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reap RENAME TABLE. --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # **) The second case is when transaction has a SW lock. @@ -2401,12 +2093,10 @@ connection default; begin; delete from t1 limit 1; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Sending: --send rename table t1 to t2; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Wait until RENAME TABLE is blocked creating pending request for X lock. let $wait_condition= @@ -2421,13 +2111,11 @@ insert into t1 values (1, 1); --echo # Unblock RENAME TABLE. commit; --echo # ---echo # Switching to connection 'mdl_con1'. connection mdl_con1; --echo # Reap RENAME TABLE. --error ER_TABLE_EXISTS_ERROR --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # Clean-up. @@ -2437,214 +2125,6 @@ disconnect mdl_con3; set debug_sync= 'RESET'; drop table t1, t2; - ---echo # ---echo # Additional coverage for some scenarios in which not quite ---echo # correct use of S metadata locks by HANDLER statement might ---echo # have caused deadlocks. ---echo # ---disable_warnings -drop table if exists t1, t2; ---enable_warnings -connect(handler_con1,localhost,root,,); -connect(handler_con2,localhost,root,,); -connection default; -create table t1 (i int); -create table t2 (j int); -insert into t1 values (1); - ---echo # ---echo # First, check scenario in which we upgrade SNRW lock to X lock ---echo # on a table while having HANDLER READ trying to acquire TL_READ ---echo # on the same table. ---echo # -handler t1 open; ---echo # ---echo # Switching to connection 'handler_con1'. -connection handler_con1; -lock table t1 write; ---echo # Upgrade SNRW to X lock. ---echo # Sending: ---send alter table t1 add column j int; ---echo # ---echo # Switching to connection 'handler_con2'. -connection handler_con2; ---echo # Wait until ALTER is blocked during upgrade. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table metadata lock" and - info = "alter table t1 add column j int"; ---source include/wait_condition.inc ---echo # ---echo # Switching to connection 'default'. -connection default; ---echo # The below statement should not cause deadlock. ---send handler t1 read first; ---echo # ---echo # Switching to connection 'handler_con1'. -connection handler_con1; ---echo # Reap ALTER TABLE. ---reap -unlock tables; ---echo # ---echo # Switching to connection 'default'. -connection default; ---echo # Reap HANDLER READ. ---reap -handler t1 close; - ---echo # ---echo # Now, check scenario in which upgrade of SNRW lock to X lock ---echo # can be blocked by HANDLER which is open in connection currently ---echo # waiting to get table-lock owned by connection doing upgrade. ---echo # -handler t1 open; ---echo # ---echo # Switching to connection 'handler_con1'. -connection handler_con1; -lock table t1 write, t2 read; ---echo # ---echo # Switching to connection 'default'. -connection default; ---echo # Execute statement which will be blocked on table-level lock ---echo # owned by connection 'handler_con1'. ---echo # Sending: ---send insert into t2 values (1); ---echo # ---echo # Switching to connection 'handler_con1'. -connection handler_con1; ---echo # Wait until INSERT is blocked on table-level lock. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table level lock" and - info = "insert into t2 values (1)"; ---source include/wait_condition.inc ---echo # Sending 'alter table t1 drop column j'. It should not cause ---echo # deadlock. -send alter table t1 drop column j; ---echo # Switching to connection 'handler_con2'. -connection handler_con2; ---echo # Wait until ALTER is blocked during upgrade. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table metadata lock" and - info = "alter table t1 drop column j"; ---source include/wait_condition.inc ---echo # ---echo # Switching to connection 'default'. -connection default; ---echo # Reap INSERT. ---error ER_LOCK_ABORTED ---reap -handler t1 close; ---echo # ---echo # Switching to connection 'handler_con1'. -connection handler_con1; ---echo # Reaping 'alter table t1 drop column j' ---reap -unlock tables; ---echo # Switching to connection 'default'. -connection default; - ---echo # Then, check the scenario in which upgrade of SNRW lock to X ---echo # lock is blocked by HANDLER which is open in connection currently ---echo # waiting to get SW lock on the same table. ---echo # -handler t1 open; ---echo # ---echo # Switching to connection 'handler_con1'. -connection handler_con1; -lock table t1 write; ---echo # ---echo # Switching to connection 'default'. -connection default; ---echo # The below insert should be blocked because active SNRW lock on 't1'. ---echo # Sending: ---send insert into t1 values (1); ---echo # ---echo # Switching to connection 'handler_con1'. -connection handler_con1; ---echo # Wait until INSERT is blocked because of SNRW lock. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table metadata lock" and - info = "insert into t1 values (1)"; ---source include/wait_condition.inc ---echo # The below ALTER TABLE will be blocked because of presence of HANDLER. ---echo # Sending: ---send alter table t1 add column j int; ---echo # ---echo # Switching to connection 'default'. -connection default; ---echo # INSERT should be chosen as victim for resolving deadlock. ---echo # Reaping INSERT. ---error ER_LOCK_DEADLOCK ---reap ---echo # Close HANDLER to unblock ALTER TABLE. -handler t1 close; ---echo # ---echo # Switching to connection 'handler_con1'. -connection handler_con1; ---echo # Reaping ALTER TABLE. ---reap -unlock tables; ---echo # ---echo # Switching to connection 'default'. -connection default; - ---echo # ---echo # Finally, test in which upgrade of SNRW lock to X lock is blocked ---echo # by HANDLER which is open in connection currently waiting to get ---echo # SR lock on the table on which lock is upgraded. ---echo # -handler t1 open; ---echo # ---echo # Switching to connection 'handler_con1'. -connection handler_con1; -lock table t1 write, t2 write; ---echo # ---echo # Switching to connection 'default'. -connection default; ---echo # The below insert should be blocked because active SNRW lock on 't1'. ---echo # Sending: ---send insert into t2 values (1); ---echo # ---echo # Switching to connection 'handler_con1'. -connection handler_con1; ---echo # Wait until INSERT is blocked because of SNRW lock. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table metadata lock" and - info = "insert into t2 values (1)"; ---source include/wait_condition.inc ---echo # The below ALTER TABLE will be blocked because of presence of HANDLER. ---echo # Sending: ---send alter table t1 drop column j; ---echo # ---echo # Switching to connection 'default'. -connection default; ---echo # INSERT should be chosen as victim for resolving deadlock. ---echo # Reaping INSERT. ---error ER_LOCK_DEADLOCK ---reap ---echo # Close HANDLER to unblock ALTER TABLE. -handler t1 close; ---echo # ---echo # Switching to connection 'handler_con1'. -connection handler_con1; ---echo # Reaping ALTER TABLE. ---reap -unlock tables; ---echo # ---echo # Switching to connection 'default'. -connection default; - ---echo # Clean-up. -disconnect handler_con1; -disconnect handler_con2; -drop tables t1, t2; - - --echo # --echo # Test coverage for basic deadlock detection in metadata --echo # locking subsystem. @@ -2668,25 +2148,21 @@ create table t4 (k int); --echo # --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; begin; insert into t1 values (1); --echo # ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; begin; insert into t2 values (1); --echo # ---echo # Switching to connection 'default'. connection default; --echo # Send: --send rename table t2 to t0, t3 to t2, t0 to t3; --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Wait until the above RENAME TABLE is blocked because it has to wait --echo # for 'deadlock_con2' which holds shared metadata lock on 't2'. @@ -2702,7 +2178,6 @@ let $wait_condition= --send select * from t2; --echo # ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Wait until the above SELECT * FROM t2 is starts waiting --echo # for an exclusive metadata lock to go away. @@ -2716,19 +2191,16 @@ let $wait_condition= commit; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap RENAME TABLE. --reap --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Reap SELECT. --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # --echo # Let us check that in the process of waiting for conflicting lock @@ -2738,7 +2210,6 @@ connection default; --send rename table t1 to t0, t3 to t1, t0 to t3; --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Wait until the above RENAME TABLE is blocked because it has to wait --echo # for 'deadlock_con1' which should still hold shared metadata lock on @@ -2752,7 +2223,6 @@ let $wait_condition= commit; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap RENAME TABLE. --reap @@ -2762,19 +2232,16 @@ connection default; --echo # --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; begin; insert into t2 values (2); --echo # ---echo # Switching to connection 'default'. connection default; --echo # Send: --send rename table t2 to t0, t1 to t2, t0 to t1; --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Wait until the above RENAME TABLE is blocked because it has to wait --echo # for 'deadlock_con1' which holds shared metadata lock on 't2'. @@ -2791,7 +2258,6 @@ let $wait_condition= select * from t1; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap RENAME TABLE. --reap @@ -2801,18 +2267,15 @@ connection default; --echo # --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; begin; insert into t2 values (1); --echo # ---echo # Switching to connection 'default'. connection default; lock table t1 write; --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # The below SELECT statement should wait for metadata lock --echo # on table 't1' and should not produce ER_LOCK_DEADLOCK @@ -2820,7 +2283,6 @@ connection deadlock_con1; --send select * from t1; --echo # ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Wait until the above SELECT * FROM t1 is starts waiting --echo # for an UNRW metadata lock to go away. @@ -2834,7 +2296,6 @@ let $wait_condition= --send rename table t1 to t0, t2 to t1, t0 to t2; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Wait till above RENAME TABLE is blocked while holding --echo # pending X lock on t1. @@ -2848,7 +2309,6 @@ let $wait_condition= unlock tables; --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Since the latest RENAME TABLE entered in deadlock with SELECT --echo # statement the latter should be aborted and emit ER_LOCK_DEADLOCK @@ -2858,13 +2318,11 @@ connection deadlock_con1; --reap --echo # ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Reap RENAME TABLE ... . --reap; --echo # ---echo # Switching to connection 'default'. connection default; drop tables t1, t2, t3, t4; @@ -2881,19 +2339,16 @@ insert into t1 values (1); select * from t1; --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; begin; select * from t1; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Send: --send alter table t1 add column j int, rename to t2; --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Wait until the above ALTER TABLE ... RENAME acquires exclusive --echo # metadata lock on 't2' and starts waiting for connection @@ -2911,7 +2366,6 @@ let $wait_condition= select * from t2; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap ALTER TABLE ... RENAME. --reap @@ -2935,7 +2389,6 @@ set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish'; --send select * from t2, t1 --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Wait till SELECT acquires MDL on 't2' and starts waiting for signal. set debug_sync= 'now WAIT_FOR locked'; @@ -2943,7 +2396,6 @@ set debug_sync= 'now WAIT_FOR locked'; --send lock tables t1 write, t2 write --echo # ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Wait until LOCK TABLES acquires SNRW lock on 't1' and is blocked --echo # while trying to acquire SNRW lock on 't1'. @@ -2956,14 +2408,12 @@ let $wait_condition= set debug_sync= 'now SIGNAL finish'; --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Reaping LOCK TABLES. --reap unlock tables; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping SELECT. It succeed and not report ER_LOCK_DEADLOCK error. --reap @@ -2983,7 +2433,6 @@ set debug_sync='alter_table_copy_after_lock_upgrade SIGNAL parked1 WAIT_FOR go1' --send alter table t1 add column j int --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Wait till ALTER acquires SNW lock and stops. set debug_sync='now WAIT_FOR parked1'; @@ -2995,7 +2444,6 @@ set debug_sync='mdl_acquire_lock_wait SIGNAL parked2 WAIT_FOR go2'; --send insert into t1 values () --echo # ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Wait till INSERT is paused. set debug_sync='now WAIT_FOR parked2'; @@ -3005,7 +2453,6 @@ set debug_sync='now WAIT_FOR parked2'; set debug_sync='now SIGNAL go1'; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping ALTER TABLE. --reap @@ -3014,7 +2461,6 @@ connection default; --send alter table t1 drop column j --echo # ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Wait until ALTER is blocked. let $wait_condition= @@ -3035,13 +2481,11 @@ let $wait_condition= set debug_sync='now SIGNAL go2'; --echo # ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Reaping INSERT. --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reaping ALTER. It should succeed and not produce ER_LOCK_DEADLOCK. --reap @@ -3063,7 +2507,6 @@ create table t2(j int); --echo # set debug_sync= 'RESET'; ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Start a statement, which will acquire SR metadata lock on t1, open it --echo # and then stop, before trying to acquire SW lock on t2 and opening it. @@ -3071,7 +2514,6 @@ set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR --echo # Sending: --send select * from t1 where i in (select j from t2 for update) ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Wait till the above SELECT stops. set debug_sync='now WAIT_FOR parked'; @@ -3080,7 +2522,6 @@ set debug_sync='now WAIT_FOR parked'; --echo # Sending: send flush tables t1, t2 with read lock; ---echo # Switching to connection 'deadlock_con3'. connection deadlock_con3; --echo # Wait until FLUSH TABLES WITH t1, t2 READ LOCK starts waiting --echo # for SELECT to close t1. @@ -3095,13 +2536,11 @@ let $wait_condition= --echo # by backing-off SELECT. As a result FTWRL should be able to finish. set debug_sync='now SIGNAL go'; ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Reap FLUSH TABLES WITH READ LOCK. reap; unlock tables; ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Reap SELECT. reap; @@ -3113,7 +2552,6 @@ reap; --echo # set debug_sync= 'RESET'; ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; set debug_sync='flush_tables_with_read_lock_after_acquire_locks SIGNAL parked WAIT_FOR go'; @@ -3122,7 +2560,6 @@ set debug_sync='flush_tables_with_read_lock_after_acquire_locks SIGNAL parked WA --echo # Sending: send flush tables t1, t2 with read lock; ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Wait till FLUSH TABLE WITH READ LOCK stops. set debug_sync='now WAIT_FOR parked'; @@ -3132,7 +2569,6 @@ set debug_sync='now WAIT_FOR parked'; --echo # Sending: send select * from t1 where i in (select j from t2 for update); ---echo # Switching to connection 'deadlock_con3'. connection deadlock_con3; --echo # Wait till the above SELECT blocks. let $wait_condition= @@ -3146,13 +2582,11 @@ let $wait_condition= --echo # backing-off SELECT. As a result FTWRL should be able to finish. set debug_sync='now SIGNAL go'; ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Reap FLUSH TABLES WITH READ LOCK. reap; unlock tables; ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Reap SELECT. reap; @@ -3163,7 +2597,6 @@ reap; --echo # set debug_sync= 'RESET'; ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Start a statement which will acquire SR metadata lock on t2, open it --echo # and then stop, before trying to acquire SR on t1 and opening it. @@ -3171,7 +2604,6 @@ set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR --echo # Sending: send select * from t2, t1; ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Wait till the above SELECT stops. set debug_sync='now WAIT_FOR parked'; @@ -3180,7 +2612,6 @@ set debug_sync='now WAIT_FOR parked'; --echo # Sending: send flush tables t2 with read lock; ---echo # Switching to connection 'deadlock_con3'. connection deadlock_con3; --echo # Wait until FLUSH TABLES WITH READ LOCK starts waiting --echo # for SELECT to close t2. @@ -3195,7 +2626,6 @@ let $wait_condition= --echo # Sending: send drop tables t1, t2; ---echo # Switching to connection 'default'. connection default; --echo # Wait until DROP TABLES starts waiting for X lock on t2. let $wait_condition= @@ -3209,25 +2639,21 @@ let $wait_condition= --echo # by backing-off SELECT. As a result, FTWRL should be able to finish. set debug_sync='now SIGNAL go'; ---echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Reap FLUSH TABLES WITH READ LOCK. reap; --echo # Unblock DROP TABLES. unlock tables; ---echo # Switching to connection 'deadlock_con3'. connection deadlock_con3; --echo # Reap DROP TABLES. reap; ---echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Reap SELECT. It should emit error about missing table. --error ER_NO_SUCH_TABLE reap; ---echo # Switching to connection 'default'. connection default; set debug_sync= 'RESET'; @@ -3251,7 +2677,6 @@ set debug_sync= 'RESET'; create table t1(i int); create table t2(j int); ---echo # Switching to connection 'con2'. connection con2; set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; @@ -3261,7 +2686,6 @@ set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR --echo # Sending: send flush tables t1, t2 with read lock; ---echo # Switching to connection 'con1'. connection con1; --echo # Wait till FLUSH TABLES <list> WITH READ LOCK stops. set debug_sync='now WAIT_FOR parked'; @@ -3271,7 +2695,6 @@ set debug_sync='now WAIT_FOR parked'; --echo # Sending: send flush tables; ---echo # Switching to connection 'default'. connection default; --echo # Wait till the above FLUSH TABLES blocks. let $wait_condition= @@ -3286,19 +2709,16 @@ let $wait_condition= --echo # which would result in assertion failures. set debug_sync='now SIGNAL go'; ---echo # Switching to connection 'con2'. connection con2; --echo # Reap FLUSH TABLES <list> WITH READ LOCK. reap; unlock tables; ---echo # Switching to connection 'con1'. connection con1; --echo # Reap FLUSH TABLES. reap; --echo # Clean-up. ---echo # Switching to connection 'default'. connection default; drop tables t1, t2; set debug_sync= 'RESET'; @@ -3328,16 +2748,13 @@ create trigger t1_bi before insert on t1 for each row create trigger t2_bi before insert on t2 for each row insert into t3 values (new.j); --echo # ---echo # Switching to connection 'con1root'. connection con1root; lock tables t4 read; --echo # ---echo # Switching to connection 'con2root'. connection con2root; --echo # Send : --send rename table t3 to t5, t4 to t3; --echo # ---echo # Switching to connection 'default'. connection default; --echo # Wait until the above RENAME TABLE adds pending requests for exclusive --echo # metadata lock on its tables and blocks due to 't4' being used by LOCK @@ -3349,7 +2766,6 @@ let $wait_condition= select count(*)= 1 from information_schema.processlist --echo # Send : --send insert into t1 values (1); --echo # ---echo # Switching to connection 'con1root'. connection con1root; --echo # Wait until INSERT statement waits due to encountering pending --echo # exclusive metadata lock on 't3'. @@ -3359,12 +2775,10 @@ let $wait_condition= select count(*)= 1 from information_schema.processlist --source include/wait_condition.inc unlock tables; --echo # ---echo # Switching to connection 'con2root'. connection con2root; --echo # Reap RENAME TABLE. --reap --echo # ---echo # Switching to connection 'default'. connection default; --echo # Reap INSERT. --reap @@ -3390,14 +2804,12 @@ connect(con2, localhost, root,,); --echo # Test 1: CREATE TABLE --echo # ---echo # Connection 2 connection con2; --echo # Start insert on the not-yet existing table --echo # Wait after taking the MDL lock SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish'; --send INSERT INTO t1 VALUES(1,"def") ---echo # Connection 1 connection default; SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Now INSERT has a MDL on the non-existent table t1. @@ -3408,13 +2820,11 @@ SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL finish'; --echo # Try to create that table. --send CREATE TABLE t1 (c1 INT, c2 VARCHAR(100), KEY(c1)) ---echo # Connection 2 --echo # Insert fails connection con2; --error ER_NO_SUCH_TABLE --reap ---echo # Connection 1 connection default; --reap; SET DEBUG_SYNC= 'RESET'; @@ -3430,14 +2840,12 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t2 (c1 INT, c2 VARCHAR(100), KEY(c1)); ---echo # Connection 2 connection con2; --echo # Start insert on the not-yet existing table --echo # Wait after taking the MDL SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish'; --send INSERT INTO t1 VALUES(1,"def") ---echo # Connection 1 connection default; SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Now INSERT has a MDL on the non-existent table t1. @@ -3448,13 +2856,11 @@ SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL finish'; --echo # Try to create that table. --send CREATE TABLE t1 LIKE t2 ---echo # Connection 2 --echo # Insert fails connection con2; --error ER_NO_SUCH_TABLE --reap ---echo # Connection 1 connection default; --reap SET DEBUG_SYNC= 'RESET'; @@ -3488,12 +2894,10 @@ insert into t1 values(1); --echo # which owner is in its turn waiting for our connection. lock tables t1 read; ---echo # Switching to connection 'con46044_2'. connection con46044_2; --echo # Sending: --send update t1 set i = 2 ---echo # Switching to connection 'con46044'. connection con46044; --echo # Waiting until UPDATE t1 SET ... is blocked. @@ -3506,7 +2910,6 @@ let $wait_condition= --echo # Sending: --send create table t2 select * from t1; ---echo # Switching to connection 'default'. connection default; --echo # Waiting until CREATE TABLE ... SELECT ... is blocked. let $wait_condition= @@ -3533,11 +2936,9 @@ select column_name from information_schema.columns select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t2'; ---echo # Switching to connection 'default'. connection default; unlock tables; ---echo # Switching to connection 'con46044'. connection con46044; --echo # Reaping CREATE TABLE ... SELECT ... . --reap @@ -3555,16 +2956,13 @@ connection con46044_2; --echo # --echo # We check same three queries to I_S in this new situation. ---echo # Switching to connection 'con46044_2'. connection con46044_2; lock tables t1 read; ---echo # Switching to connection 'con46044_3'. connection con46044_3; --echo # Sending: send update t1 set i = 3; ---echo # Switching to connection 'con46044'. connection con46044; --echo # Waiting until UPDATE t1 SET ... is blocked. @@ -3577,7 +2975,6 @@ let $wait_condition= --echo # Sending: --send create table t2 select * from t1; ---echo # Switching to connection 'default'. connection default; --echo # Waiting until CREATE TABLE ... SELECT ... is blocked. let $wait_condition= @@ -3590,7 +2987,6 @@ let $wait_condition= --echo # Sending: --send show fields from t2; ---echo # Switching to connection 'con46044_2'. connection con46044_2; --echo # Wait until SHOW FIELDS gets blocked. let $wait_condition= @@ -3601,12 +2997,10 @@ let $wait_condition= unlock tables; ---echo # Switching to connection 'con46044'. connection con46044; --echo # Reaping CREATE TABLE ... SELECT ... . --reap ---echo # Switching to connection 'default'. connection default; --echo # Reaping SHOW FIELDS ... --reap @@ -3616,16 +3010,13 @@ connection con46044_3; --echo # Reaping UPDATE t1 statement --reap ---echo # Switching to connection 'con46044_2'. connection con46044_2; lock tables t1 read; ---echo # Switching to connection 'con46044_3'. connection con46044_3; --echo # Sending: --send update t1 set i = 4 ---echo # Switching to connection 'con46044'. connection con46044; --echo # Waiting until UPDATE t1 SET ... is blocked. @@ -3638,7 +3029,6 @@ let $wait_condition= --echo # Sending: --send create table t2 select * from t1; ---echo # Switching to connection 'default'. connection default; --echo # Waiting until CREATE TABLE ... SELECT ... is blocked. let $wait_condition= @@ -3651,7 +3041,6 @@ let $wait_condition= --echo # Sending: --send select column_name from information_schema.columns where table_schema='test' and table_name='t2'; ---echo # Switching to connection 'con46044_2'. connection con46044_2; --echo # Wait until SELECT COLUMN_NAME FROM I_S.COLUMNS gets blocked. let $wait_condition= @@ -3662,12 +3051,10 @@ let $wait_condition= unlock tables; ---echo # Switching to connection 'con46044'. connection con46044; --echo # Reaping CREATE TABLE ... SELECT ... . --reap ---echo # Switching to connection 'default'. connection default; --echo # Reaping SELECT COLUMN_NAME FROM I_S.COLUMNS --reap @@ -3677,16 +3064,13 @@ connection con46044_3; --echo # Reaping UPDATE t1 statement --reap ---echo # Switching to connection 'con46044_2'. connection con46044_2; lock tables t1 read; ---echo # Switching to connection 'con46044_3'. connection con46044_3; --echo # Sending: --send update t1 set i = 5 ---echo # Switching to connection 'con46044'. connection con46044; --echo # Waiting until UPDATE t1 SET ... is blocked. @@ -3699,7 +3083,6 @@ let $wait_condition= --echo # Sending: --send create table t2 select * from t1; ---echo # Switching to connection 'default'. connection default; --echo # Waiting until CREATE TABLE ... SELECT ... is blocked. let $wait_condition= @@ -3713,7 +3096,6 @@ let $wait_condition= --echo # Sending: --send select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t2'; ---echo # Switching to connection 'con46044_2'. connection con46044_2; --echo # Wait until SELECT ... FROM I_S.TABLES gets blocked. let $wait_condition= @@ -3724,12 +3106,10 @@ let $wait_condition= unlock tables; ---echo # Switching to connection 'con46044'. connection con46044; --echo # Reaping CREATE TABLE ... SELECT ... . --reap ---echo # Switching to connection 'default'. connection default; --echo # Reaping SELECT ... FROM I_S.TABLES --reap @@ -3739,7 +3119,6 @@ connection con46044_3; --echo # Reaping UPDATE t1 statement --reap ---echo # Switching to connection 'default'. connection default; --echo # Clean-up. disconnect con46044; @@ -3765,13 +3144,11 @@ begin; select * from t1 where c2 = 3; --echo # ---echo # Switching to connection 'con46273'. connection con46273; set debug_sync='alter_table_copy_after_lock_upgrade SIGNAL alter_table_locked WAIT_FOR alter_go'; --send alter table t1 add column e int, rename to t2; --echo # ---echo # Switching to connection 'default'. connection default; set debug_sync='now WAIT_FOR alter_table_locked'; set debug_sync='mdl_acquire_lock_wait SIGNAL alter_go'; @@ -3782,13 +3159,11 @@ set debug_sync='mdl_acquire_lock_wait SIGNAL alter_go'; update t1 set c3=c3+1 where c2 = 3; --echo # ---echo # Switching to connection 'con46273'. connection con46273; --echo # Reap ALTER TABLE. --reap --echo # ---echo # Switching to connection 'default'. connection default; disconnect con46273; --echo # Clean-up. @@ -3807,12 +3182,10 @@ connect (con46673, localhost, root,,); connection default; create table t1 (i int); ---echo # Switching to connection 'con46673'. connection con46673; begin; insert into t1 values (1); ---echo # Switching to connection 'default'. connection default; --echo # Statement below should not get blocked. And if after some --echo # changes to code it is there should not be a deadlock between @@ -3820,12 +3193,10 @@ connection default; flush tables with read lock; unlock tables; ---echo # Switching to connection 'con46673'. connection con46673; delete from t1 where i = 1; commit; ---echo # Switching to connection 'default'. connection default; --echo # Clean-up disconnect con46673; @@ -3841,13 +3212,11 @@ connect (con2, localhost, root); --echo # Test 1: CREATE PROCEDURE ---echo # Connection 1 connection default; --echo # Start CREATE PROCEDURE and open mysql.proc SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait'; --send CREATE PROCEDURE p1() SELECT 1 ---echo # Connection 2 connection con2; SET DEBUG_SYNC= 'now WAIT_FOR table_opened'; --echo # Check that FLUSH must wait to get the GRL @@ -3855,16 +3224,13 @@ SET DEBUG_SYNC= 'now WAIT_FOR table_opened'; SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL grlwait'; --send FLUSH TABLES WITH READ LOCK ---echo # Connection 1 connection default; --reap ---echo # Connection 2 connection con2; --reap UNLOCK TABLES; ---echo # Connection 1 connection default; SET DEBUG_SYNC= 'RESET'; @@ -3875,7 +3241,6 @@ connection default; SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait'; --send DROP PROCEDURE p1 ---echo # Connection 2 connection con2; SET DEBUG_SYNC= 'now WAIT_FOR table_opened'; --echo # Check that FLUSH must wait to get the GRL @@ -3883,7 +3248,6 @@ SET DEBUG_SYNC= 'now WAIT_FOR table_opened'; SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL grlwait'; --send FLUSH TABLES WITH READ LOCK ---echo # Connection 1 connection default; --echo # Once FLUSH TABLES WITH READ LOCK starts waiting --echo # DROP PROCEDURE will be waked up and will drop @@ -3893,13 +3257,11 @@ connection default; --echo # Reaping DROP PROCEDURE. --reap ---echo # Connection 2 connection con2; --echo # Reaping FTWRL. --reap UNLOCK TABLES; ---echo # Connection 1 connection default; SET DEBUG_SYNC= 'RESET'; @@ -4015,13 +3377,11 @@ connect (con50913_2,localhost,root); connection default; create table t1 (i int) engine=InnoDB; ---echo # Switching to connection 'con50913_1'. connection con50913_1; set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL parked WAIT_FOR go'; --echo # Sending: --send alter table t1 add column j int, ALGORITHM=COPY ---echo # Switching to connection 'default'. connection default; --echo # Wait until ALTER TABLE gets blocked on a sync point after --echo # acquiring thr_lock.c lock. @@ -4031,7 +3391,6 @@ set debug_sync= 'now WAIT_FOR parked'; --echo # Sending: --send truncate table t1 ---echo # Switching to connection 'con50913_2'. connection con50913_2; --echo # Wait until TRUNCATE TABLE is blocked on MDL lock. let $wait_condition= @@ -4042,12 +3401,10 @@ let $wait_condition= --echo # Unblock ALTER TABLE. set debug_sync= 'now SIGNAL go'; ---echo # Switching to connection 'con50913_1'. connection con50913_1; --echo # Reaping ALTER TABLE. --reap ---echo # Switching to connection 'default'. connection default; --echo # Reaping TRUNCATE TABLE. --reap @@ -4074,17 +3431,14 @@ connect (con3,localhost,root); connection default; create table t1 (i int); ---echo # Switching to connection 'con1'. connection con1; begin; select * from t1; ---echo # Switching to connection 'con2'. connection con2; begin; select * from t1; ---echo # Switching to connection 'default'. connection default; --echo # Start ALTER TABLE which will acquire SNW lock and --echo # table lock and get blocked on sync point. @@ -4092,19 +3446,16 @@ set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL parked WAIT_FOR go'; --echo # Sending: --send alter table t1 add column j int ---echo # Switching to connection 'con1'. connection con1; --echo # Wait until ALTER TABLE gets blocked on a sync point. set debug_sync= 'now WAIT_FOR parked'; --echo # Sending: --send insert into t1 values (1) ---echo # Switching to connection 'con2'. connection con2; --echo # Sending: --send insert into t1 values (1) ---echo # Switching to connection 'con3'. connection con3; --echo # Wait until both 'con1' and 'con2' are blocked trying to acquire --echo # SW lock on the table. @@ -4119,7 +3470,6 @@ let $wait_condition= --echo # should be aborted with ER_LOCK_DEADLOCK errors. set debug_sync= 'now SIGNAL go'; ---echo # Switching to connection 'con1'. connection con1; --echo # Reaping INSERT. It should end with ER_LOCK_DEADLOCK error and --echo # not wait indefinitely (as it happened before the bugfix). @@ -4127,14 +3477,12 @@ connection con1; --reap commit; ---echo # Switching to connection 'con2'. connection con2; --echo # Reaping INSERT. --error ER_LOCK_DEADLOCK --reap commit; ---echo # Switching to connection 'default'. connection default; --echo # Reap ALTER TABLE. --reap @@ -4165,32 +3513,26 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT) ENGINE=InnoDB; INSERT INTO t1 VALUES (1),(2),(3); ---echo # Connection: con1 connection con1; LOCK TABLES t1 WRITE; SET debug_sync='upgrade_lock_for_truncate SIGNAL parked_truncate WAIT_FOR go_truncate'; send TRUNCATE TABLE t1; connection default; ---echo # Connection: default SET debug_sync='now WAIT_FOR parked_truncate'; connection con2; ---echo # Connection: con2 SET debug_sync='after_open_table_ignore_flush SIGNAL parked_show WAIT_FOR go_show'; send SHOW FIELDS FROM t1; connection default; ---echo # Connection: default SET debug_sync='now WAIT_FOR parked_show'; connection con3; ---echo # Connection: con3 SET debug_sync='after_flush_unlock SIGNAL parked_flush WAIT_FOR go_flush'; send FLUSH TABLES t1; connection default; ---echo # Connection: default SET debug_sync='now WAIT_FOR parked_flush'; SET debug_sync='now SIGNAL go_truncate'; --echo # Ensure that truncate waits for a exclusive lock @@ -4200,22 +3542,18 @@ let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist SET debug_sync= 'now SIGNAL go_show'; connection con1; ---echo # Connection: con1 (TRUNCATE) --echo # Reaping... reap; UNLOCK TABLES; connection con2; ---echo # Connection: con2 (SHOW FIELDS FROM t1) --echo # Reaping... reap; connection default; ---echo # Connection: default SET debug_sync= 'now SIGNAL go_flush'; connection con3; ---echo # Connection: con3 (FLUSH TABLES t1) --echo # Reaping... reap; @@ -4224,7 +3562,6 @@ disconnect con2; disconnect con3; connection default; ---echo # Connection: default SET debug_sync= 'RESET'; DROP TABLE t1; @@ -4268,20 +3605,17 @@ connect (con3, localhost, root); --echo # not database DDL on different databases. Tests X vs X lock. --echo # ---echo # Connection default connection default; SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked'; --echo # Sending: --send CREATE DATABASE db1 ---echo # Connection con2 connection con2; SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Sending: # This should block. --send CREATE DATABASE db1 ---echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Waiting for schema metadata lock' AND info='CREATE DATABASE db1'; @@ -4292,12 +3626,10 @@ ALTER DATABASE db2 DEFAULT CHARACTER SET utf8; DROP DATABASE db2; SET DEBUG_SYNC= 'now SIGNAL blocked'; ---echo # Connection default connection default; --echo # Reaping: CREATE DATABASE db1 --reap ---echo # Connection con2 connection con2; --echo # Reaping: CREATE DATABASE db1 --error ER_DB_CREATE_EXISTS @@ -4308,20 +3640,17 @@ connection con2; --echo # not database DDL on different databases. Tests X vs X lock. --echo # ---echo # Connection default connection default; SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked'; --echo # Sending: --send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8 ---echo # Connection con2 connection con2; SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Sending: # This should block. --send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8 ---echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Waiting for schema metadata lock' @@ -4333,42 +3662,35 @@ ALTER DATABASE db2 DEFAULT CHARACTER SET utf8; DROP DATABASE db2; SET DEBUG_SYNC= 'now SIGNAL blocked'; ---echo # Connection default connection default; --echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8 --reap ---echo # Connection con2 connection con2; --echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8 --reap ---echo # Connection default connection default; SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked'; --echo # Sending: --send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8 ---echo # Connection con2 connection con2; SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Sending: # This should also block. --send DROP DATABASE db1 ---echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Waiting for schema metadata lock' AND info='DROP DATABASE db1'; --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL blocked'; ---echo # Connection default connection default; --echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8 --reap ---echo # Connection con2 connection con2; --echo # Reaping: DROP DATABASE db1 --reap @@ -4387,20 +3709,17 @@ let $MYSQLD_DATADIR= `select @@datadir`; --mkdir $MYSQLD_DATADIR/a-b-c-d --copy_file $MYSQLD_DATADIR/db1/db.opt $MYSQLD_DATADIR/a-b-c-d/db.opt ---echo # Connection default connection default; SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked'; --echo # Sending: --send ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME ---echo # Connection con2 connection con2; SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Sending: # This should block. --send ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME ---echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Waiting for schema metadata lock' @@ -4410,12 +3729,10 @@ let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist ALTER DATABASE `#mysql50#a-b-c-d` UPGRADE DATA DIRECTORY NAME; SET DEBUG_SYNC= 'now SIGNAL blocked'; ---echo # Connection default connection default; --echo # Reaping: ALTER DATABASE '#mysql50#a-b-c' UPGRADE DATA DIRECTORY NAME --reap ---echo # Connection con2 connection con2; --echo # Reaping: ALTER DATABASE '#mysql50#a-b-c' UPGRADE DATA DIRECTORY NAME --error ER_BAD_DB_ERROR @@ -4428,20 +3745,17 @@ DROP DATABASE `a-b-c-d`; --echo # not database DDL on different databases. Tests X vs X lock. --echo # ---echo # Connection default connection default; SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked'; --echo # Sending: --send DROP DATABASE db1 ---echo # Connection con2 connection con2; SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Sending: # This should block. --send DROP DATABASE db1 ---echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Waiting for schema metadata lock' AND info='DROP DATABASE db1'; @@ -4452,32 +3766,27 @@ ALTER DATABASE db2 DEFAULT CHARACTER SET utf8; DROP DATABASE db2; SET DEBUG_SYNC= 'now SIGNAL blocked'; ---echo # Connection default connection default; --echo # Reaping: DROP DATABASE db1 --reap ---echo # Connection con2 connection con2; --echo # Reaping: DROP DATABASE db1 --error ER_DB_DROP_EXISTS --reap ---echo # Connection default connection default; CREATE DATABASE db1; SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked'; --echo # Sending: --send DROP DATABASE db1 ---echo # Connection con2 connection con2; SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Sending: # This should also block. --send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8 ---echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Waiting for schema metadata lock' @@ -4485,12 +3794,10 @@ let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL blocked'; ---echo # Connection default connection default; --echo # Reaping: DROP DATABASE db1 --reap ---echo # Connection con2 connection con2; --echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8 # Error 1 is from ALTER DATABASE when the database does not exist. @@ -4504,21 +3811,18 @@ connection con2; --echo # Tests X vs IX lock. --echo # ---echo # Connection default connection default; CREATE DATABASE db1; SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked'; --echo # Sending: --send DROP DATABASE db1 ---echo # Connection con2 connection con2; SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Sending: # This should block. --send CREATE TABLE db1.t1 (a INT) ---echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Waiting for schema metadata lock' AND @@ -4526,12 +3830,10 @@ let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL blocked'; ---echo # Connection default connection default; --echo # Reaping: DROP DATABASE db1 --reap ---echo # Connection con2 connection con2; --echo # Reaping: CREATE TABLE db1.t1 (a INT) --error ER_BAD_DB_ERROR @@ -4542,7 +3844,6 @@ connection con2; --echo # Tests X vs IX lock. --echo # ---echo # Connection default connection default; CREATE DATABASE db1; CREATE TABLE db1.t1 (a INT); @@ -4550,14 +3851,12 @@ SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked'; --echo # Sending: --send DROP DATABASE db1 ---echo # Connection con2 connection con2; SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Sending: # This should block. --send RENAME TABLE db1.t1 TO test.t1 ---echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Waiting for schema metadata lock' AND @@ -4565,18 +3864,15 @@ let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL blocked'; ---echo # Connection default connection default; --echo # Reaping: DROP DATABASE db1 --reap ---echo # Connection con2 connection con2; --echo # Reaping: RENAME TABLE db1.t1 TO test.t1 --error ER_NO_SUCH_TABLE --reap ---echo # Connection default connection default; CREATE DATABASE db1; CREATE TABLE test.t2 (a INT); @@ -4584,14 +3880,12 @@ SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked'; --echo # Sending: --send DROP DATABASE db1 ---echo # Connection con2 connection con2; SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Sending: # This should block. --send RENAME TABLE test.t2 TO db1.t2 ---echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Waiting for schema metadata lock' AND @@ -4599,12 +3893,10 @@ let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL blocked'; ---echo # Connection default connection default; --echo # Reaping: DROP DATABASE db1 --reap ---echo # Connection con2 connection con2; --echo # Reaping: RENAME TABLE test.t2 TO db1.t2 # Error 7 is from RENAME TABLE where the target database does not exist. @@ -4619,7 +3911,6 @@ DROP TABLE test.t2; --echo # Tests X vs IX lock. --echo # ---echo # Connection default connection default; CREATE DATABASE db1; CREATE TABLE db1.t1 (a INT); @@ -4627,32 +3918,27 @@ SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked'; --echo # Sending: --send DROP DATABASE db1 ---echo # Connection con2 connection con2; SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Sending: # This should block. --send DROP TABLE db1.t1 ---echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Waiting for schema metadata lock' AND info='DROP TABLE db1.t1'; --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL blocked'; ---echo # Connection default connection default; --echo # Reaping: DROP DATABASE db1 --reap ---echo # Connection con2 connection con2; --echo # Reaping: DROP TABLE db1.t1 --error ER_BAD_TABLE_ERROR --reap ---echo # Connection default connection default; disconnect con2; disconnect con3; @@ -4671,16 +3957,13 @@ CREATE TABLE db1.t1(a INT); connect(con2, localhost, root); connect(con3, localhost, root); ---echo # Connection default connection default; FLUSH TABLE WITH READ LOCK; ---echo # Connection con2 connection con2; # IX global lock should block --send CREATE TABLE db1.t2(a INT) ---echo # Connection default connection default; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Waiting for global read lock' @@ -4688,21 +3971,17 @@ let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist --source include/wait_condition.inc UNLOCK TABLES; ---echo # Connection con2 connection con2; --echo # Reaping CREATE TABLE db1.t2(a INT) --reap ---echo # Connection default connection default; FLUSH TABLE WITH READ LOCK; ---echo # Connection con2 connection con2; # X global lock should block --send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8 ---echo # Connection default connection default; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Waiting for global read lock' @@ -4710,22 +3989,18 @@ let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist --source include/wait_condition.inc UNLOCK TABLES; ---echo # Connection con2 connection con2; --echo # Reaping ALTER DATABASE db1 DEFAULT CHARACTER SET utf8 --reap ---echo # Connection default connection default; FLUSH TABLE WITH READ LOCK; ---echo # Connection con2 connection con2; # S global lock should not block FLUSH TABLE WITH READ LOCK; UNLOCK TABLES; ---echo # Connection default connection default; UNLOCK TABLES; DROP DATABASE db1; @@ -4752,7 +4027,6 @@ connect(con1, localhost, root); connect(con2, localhost, root); connect(con3, localhost, root); ---echo # Connection con1 connection con1; --echo # We need EXECUTE 2 since ALTER TABLE does SU => SNW => X and we want --echo # to stop at the second upgrade. @@ -4760,7 +4034,6 @@ SET DEBUG_SYNC= 'mdl_upgrade_lock SIGNAL upgrade WAIT_FOR continue EXECUTE 2'; --echo # Sending: --send ALTER TABLE m1 engine=MERGE UNION=(t2, t1) ---echo # Connection con2 connection con2; --echo # Waiting for ALTER TABLE to try lock upgrade SET DEBUG_SYNC= 'now WAIT_FOR upgrade'; @@ -4769,7 +4042,6 @@ SET DEBUG_SYNC= 'now WAIT_FOR upgrade'; --echo # Sending: --send DELETE FROM t2 WHERE a = 3 ---echo # Connection default connection con3; --echo # Check that DELETE is waiting on a metadata lock and not a table lock. let $wait_condition= @@ -4786,18 +4058,15 @@ connection default; --echo # Resuming ALTER TABLE SET DEBUG_SYNC= 'now SIGNAL continue'; ---echo # Connection con1 connection con1; --echo # Reaping: ALTER TABLE m1 engine=MERGE UNION=(t2, t1) --reap ---echo # Connection con2 connection con2; --echo # Reaping: DELETE FROM t2 WHERE a = 3 --reap connection con3; --echo # Reaping: SELECT * FROM m1 WHERE a < 3 --reap ---echo # Connection default connection default; DROP TABLE m1, t1, t2; SET DEBUG_SYNC= 'RESET'; |