diff options
Diffstat (limited to 'mysql-test/main/lock_multi.test')
-rw-r--r-- | mysql-test/main/lock_multi.test | 68 |
1 files changed, 44 insertions, 24 deletions
diff --git a/mysql-test/main/lock_multi.test b/mysql-test/main/lock_multi.test index ce901126ce5..5cc7219b01d 100644 --- a/mysql-test/main/lock_multi.test +++ b/mysql-test/main/lock_multi.test @@ -191,18 +191,18 @@ connection reader; USE mysql; # Note: This must be a multi-table select, otherwise the deadlock will not occur send -SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1; +SELECT global_priv.host FROM global_priv, db WHERE global_priv.user = db.user LIMIT 1; # connection locker; # Sleep a bit till the select of connection reader is in work and hangs let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE state = "Waiting for table metadata lock" AND info = - "SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1"; + "SELECT global_priv.host FROM global_priv, db WHERE global_priv.user = db.user LIMIT 1"; --source include/wait_condition.inc # Make test case independent from earlier grants. --replace_result "Table is already up to date" "OK" -OPTIMIZE TABLES columns_priv, db, user; +OPTIMIZE TABLES columns_priv, db, global_priv; UNLOCK TABLES; # connection reader; @@ -229,7 +229,7 @@ connection writer; # Sleep a bit till the flush of connection locker is in work and hangs let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock" and + where state = "Waiting for backup lock" and info = "FLUSH TABLES WITH READ LOCK"; --source include/wait_condition.inc # This must not block. @@ -261,7 +261,7 @@ connection writer; # Sleep a bit till the flush of connection locker is in work and hangs let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock" and + where state = "Waiting for backup lock" and info = "FLUSH TABLES WITH READ LOCK"; --source include/wait_condition.inc --error ER_TABLE_NOT_LOCKED @@ -298,10 +298,10 @@ DROP DATABASE mysqltest_1; # When fixed: Reject dropping db because of the read lock. connection con1; # Wait a bit so that the session con2 is in state -# "Waiting for global read lock" +# "Waiting for backup lock" let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock" + where state = "Waiting for backup lock" and info = "DROP DATABASE mysqltest_1"; --source include/wait_condition.inc --error ER_CANT_UPDATE_WITH_READLOCK @@ -377,7 +377,7 @@ send flush tables with read lock; connection con5; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock" and + where state = "Waiting for backup lock" and info = "flush tables with read lock"; --source include/wait_condition.inc --echo # global read lock is taken @@ -386,14 +386,19 @@ send select * from t2 for update; connection con5; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock" and + where state = "Waiting for backup lock" and info = "select * from t2 for update"; --source include/wait_condition.inc --echo # waiting for release of read lock connection con4; --echo # would hang and later cause a deadlock -flush tables t2; +--send flush tables t2 connection con1; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table metadata lock" and + info = "flush tables t2"; +--source include/wait_condition.inc --echo # clean up unlock tables; connection con2; @@ -401,6 +406,8 @@ connection con2; unlock tables; connection con3; --reap +connection con4; +--reap connection default; disconnect con5; disconnect con4; @@ -432,16 +439,23 @@ send update t2 set a = 1; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock" and + where state = "Waiting for backup lock" and info = "update t2 set a = 1"; --source include/wait_condition.inc --echo # statement is waiting for release of read lock connection con2; -flush table t2; +--send flush table t2 connection default; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table metadata lock" and + info = "flush table t2"; +--source include/wait_condition.inc unlock tables; connection con1; --reap +connection con2; +--reap --echo # --echo # LOCK TABLES .. WRITE @@ -454,7 +468,7 @@ send lock tables t2 write; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock" and + where state = "Waiting for backup lock" and info = "lock tables t2 write"; --source include/wait_condition.inc --echo # statement is waiting for release of read lock @@ -542,7 +556,7 @@ connection flush; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock" and + where state = "Waiting for backup lock" and info = "flush tables with read lock"; --source include/wait_condition.inc alter table t1 add column j int; @@ -550,14 +564,14 @@ connect (insert,localhost,root,,test,,); connection insert; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock" and + where state = "Waiting for backup lock" and info = "flush tables with read lock"; --source include/wait_condition.inc ---send insert into t1 values (1,2); +--send insert into t1 values (1,2) connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock" and + where state = "Waiting for table metadata lock" and info = "insert into t1 values (1,2)"; --source include/wait_condition.inc unlock tables; @@ -565,7 +579,7 @@ connection flush; --reap let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock" and + where state = "Waiting for backup lock" and info = "insert into t1 values (1,2)"; --source include/wait_condition.inc select * from t1; @@ -598,12 +612,12 @@ connection flush; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock"; + where state = "Waiting for backup lock"; --source include/wait_condition.inc flush tables; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock"; + where state = "Waiting for backup lock"; --source include/wait_condition.inc unlock tables; connection flush; @@ -664,12 +678,12 @@ connection flush; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock"; + where state = "Waiting for backup lock"; --source include/wait_condition.inc flush tables; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global read lock"; + where state = "Waiting for backup lock"; --source include/wait_condition.inc drop table t1; connection flush; @@ -931,13 +945,19 @@ connection default; LOCK TABLE t1 READ; connection con3; + +# first test that flush tables doesn't block +FLUSH TABLES; + +# Check the FLUSH TABLES t1 waits until table lock is released + --echo # Sending: ---send FLUSH TABLES +--send FLUSH TABLES t1 connection con2; let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = "Waiting for table flush" AND info = "FLUSH TABLES"; + WHERE state = "Waiting for table metadata lock" AND info = "FLUSH TABLES t1"; --source include/wait_condition.inc --error ER_LOCK_WAIT_TIMEOUT SELECT * FROM t1; |