diff options
author | Matthias Leich <Matthias.Leich@sun.com> | 2009-03-03 21:34:18 +0100 |
---|---|---|
committer | Matthias Leich <Matthias.Leich@sun.com> | 2009-03-03 21:34:18 +0100 |
commit | 140cc614c944154282fce87064f5e3552406a14c (patch) | |
tree | f6603b5abdb12bdc27567a91a4cf7efd469d9c8f /mysql-test/t/lock_multi.test | |
parent | e1a197caba314ab7c9fdc608fb57787367236c3d (diff) | |
download | mariadb-git-140cc614c944154282fce87064f5e3552406a14c.tar.gz |
Last slice of fix for Bug#42003 tests missing the disconnect of connections <> default
+ Fix for Bug#43114 wait_until_count_sessions too restrictive, random PB failures
+ Removal of a lot of other weaknesses found
+ modifications according to review
Diffstat (limited to 'mysql-test/t/lock_multi.test')
-rw-r--r-- | mysql-test/t/lock_multi.test | 201 |
1 files changed, 143 insertions, 58 deletions
diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index 089a60edb3d..206ab20596d 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -1,4 +1,8 @@ -- source include/not_embedded.inc + +# Save the initial number of concurrent sessions +--source include/count_sessions.inc + --disable_warnings drop table if exists t1,t2; --enable_warnings @@ -14,12 +18,23 @@ create table t1(n int); insert into t1 values (1); lock tables t1 write; connection writer; -send update low_priority t1 set n = 4; +send +update low_priority t1 set n = 4; connection reader; ---sleep 2 -send select n from t1; +# Sleep a bit till the update of connection writer is in work and hangs +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Locked'; +--source include/wait_show_condition.inc +send +select n from t1; connection locker; ---sleep 2 +# Sleep a bit till the select of connection reader is in work and hangs +# Here we cannot use include/wait_show_condition.inc because this routine +# cannot count the number of 'Locked' sessions or access two columns within +# the same query_get_value call. +--sleep 3 unlock tables; connection writer; reap; @@ -32,12 +47,23 @@ create table t1(n int); insert into t1 values (1); lock tables t1 read; connection writer; -send update low_priority t1 set n = 4; +send +update low_priority t1 set n = 4; connection reader; ---sleep 2 -send select n from t1; +# Sleep a bit till the update of connection writer is in work and hangs +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Locked'; +--source include/wait_show_condition.inc +# +send +select n from t1; connection locker; ---sleep 2 +# Sleep a bit till the select of connection reader is in work and hangs +# Here we cannot use include/wait_show_condition.inc. +--sleep 3 +# unlock tables; connection writer; reap; @@ -58,10 +84,15 @@ insert into t1 values(2,2); insert into t2 values(1,2); lock table t1 read; connection writer; ---sleep 2 -send update t1,t2 set c=a where b=d; +# mleich: IMHO the "send is not necessary because the update should not block. +# But it will save some runtime in case we block because of an error. +send +update t1,t2 set c=a where b=d; connection reader; ---sleep 2 +# Sleep a bit till the update of connection writer is finished +# Here we cannot use include/wait_show_condition.inc. +--sleep 3 +# select c from t2; connection writer; reap; @@ -70,7 +101,7 @@ drop table t1; drop table t2; # -# Test problem when using locks on many tables and droping a table that +# Test problem when using locks on many tables and dropping a table that # is to-be-locked by another thread # @@ -79,11 +110,18 @@ create table t1 (a int); create table t2 (a int); lock table t1 write, t2 write; connection reader; -send insert t1 select * from t2; +send +insert t1 select * from t2; connection locker; +# Sleep a bit till the insert of connection reader is in work and hangs +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Locked'; +--source include/wait_show_condition.inc drop table t2; connection reader; ---error 1146 +--error ER_NO_SUCH_TABLE reap; connection locker; drop table t1; @@ -91,7 +129,7 @@ drop table t1; # End of 4.1 tests # -# BUG#9998 - MySQL client hangs on USE "database" +# Bug#9998 MySQL client hangs on USE "database" # create table t1(a int); lock tables t1 write; @@ -102,7 +140,7 @@ unlock tables; drop table t1; # -# Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock +# Bug#19815 CREATE/RENAME/DROP DATABASE can deadlock on a global read lock # connect (con1,localhost,root,,); connect (con2,localhost,root,,); @@ -114,12 +152,18 @@ FLUSH TABLES WITH READ LOCK; # With bug in place: acquire LOCK_mysql_create_table and # wait in wait_if_global_read_lock(). connection con2; -send DROP DATABASE mysqltest_1; ---sleep 1 +send +DROP DATABASE mysqltest_1; # # With bug in place: try to acquire LOCK_mysql_create_table... # 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 release of readlock" +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Waiting for release of readlock'; +--source include/wait_show_condition.inc --error ER_CANT_UPDATE_WITH_READLOCK DROP DATABASE mysqltest_1; UNLOCK TABLES; @@ -135,26 +179,33 @@ disconnect con2; --error ER_DB_DROP_EXISTS DROP DATABASE mysqltest_1; + # -# Bug#16986 - Deadlock condition with MyISAM tables +# Bug#16986 Deadlock condition with MyISAM tables # # Need a matching user in mysql.user for multi-table select --source include/add_anonymous_users.inc connection locker; -use mysql; +USE mysql; LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE; FLUSH TABLES; --sleep 1 # 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; ---sleep 1 +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; # connection locker; +# Sleep a bit till the select of connection reader is in work and hangs +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Locked'; +--source include/wait_show_condition.inc # Make test case independent from earlier grants. --replace_result "Table is already up to date" "OK" OPTIMIZE TABLES columns_priv, db, host, user; @@ -162,7 +213,7 @@ UNLOCK TABLES; # connection reader; reap; -use test; +USE test; # connection locker; use test; @@ -177,11 +228,17 @@ LOCK TABLE t1 WRITE; # # This waits until t1 is unlocked. connection locker; -send FLUSH TABLES WITH READ LOCK; ---sleep 1 +send +FLUSH TABLES WITH READ LOCK; # # This must not block. connection writer; +# Sleep a bit till the flush of connection locker is in work and hangs +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Flushing tables'; +--source include/wait_show_condition.inc CREATE TABLE t2 (c1 int); UNLOCK TABLES; # @@ -201,12 +258,18 @@ LOCK TABLE t1 WRITE; # # This waits until t1 is unlocked. connection locker; -send FLUSH TABLES WITH READ LOCK; ---sleep 1 +send +FLUSH TABLES WITH READ LOCK; # # This must not block. connection writer; ---error 1100 +# Sleep a bit till the flush of connection locker is in work and hangs +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Flushing tables'; +--source include/wait_show_condition.inc +--error ER_TABLE_NOT_LOCKED CREATE TABLE t2 AS SELECT * FROM t1; UNLOCK TABLES; # @@ -220,8 +283,9 @@ DROP TABLE t1; --source include/delete_anonymous_users.inc + # -# Bug #17264: MySQL Server freeze +# Bug#17264 MySQL Server freeze # connection locker; # Disable warnings to allow test to run also without InnoDB @@ -230,17 +294,27 @@ create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) e --enable_warnings lock tables t1 write; connection writer; ---sleep 2 +# mleich: I have doubts if the next sleep is really necessary +# --sleep 2 delimiter //; -send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // +send +alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // delimiter ;// connection reader; ---sleep 2 +# Wait till connection writer is blocked +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Locked'; +--source include/wait_show_condition.inc delimiter //; -send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // +send +alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // delimiter ;// connection locker; ---sleep 2 +# Wait till connection reader is blocked +# Here we cannot use include/wait_show_condition.inc. +--sleep 3 unlock tables; connection writer; reap; @@ -263,7 +337,7 @@ lock tables t1 read; --echo connection: writer connection writer; let $ID= `select connection_id()`; ---send create table t2 like t1; +send create table t2 like t1; --echo connection: default connection default; let $show_type= open tables where in_use=2 and name_locked=1; @@ -282,8 +356,8 @@ connection default; drop table t1; # -# Bug #38691: segfault/abort in ``UPDATE ...JOIN'' while -# ``FLUSH TABLES WITH READ LOCK'' +# Bug#38691 segfault/abort in ``UPDATE ...JOIN'' while +# ``FLUSH TABLES WITH READ LOCK'' # --connection default @@ -354,7 +428,7 @@ while ($i) { dec $i; --connection locker ---error 0,1060 +--error 0,ER_DUP_FIELDNAME ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL; UPDATE t2 SET a=b; @@ -362,11 +436,11 @@ while ($i) { --send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b --connection locker ---error 0,1091 +--error 0,ER_CANT_DROP_FIELD_OR_KEY ALTER TABLE t2 DROP COLUMN a; --connection writer ---error 0,1054 +--error 0,ER_BAD_FIELD_ERROR --reap } --enable_query_log @@ -379,7 +453,7 @@ while ($i) { dec $i; --connection locker ---error 0,1060 +--error 0,ER_DUP_FIELDNAME ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL; UPDATE t2 SET a=b; @@ -388,11 +462,11 @@ while ($i) { --send EXECUTE stmt --connection locker ---error 0,1091 +--error 0,ER_CANT_DROP_FIELD_OR_KEY ALTER TABLE t2 DROP COLUMN a; --connection writer ---error 0,1054 +--error 0,ER_BAD_FIELD_ERROR --reap } @@ -400,8 +474,9 @@ while ($i) { --connection default DROP TABLE t1, t2, t3; + # -# Bug#38499: flush tables and multitable table update with derived table cause +# Bug#38499: flush tables and multitable table update with derived table cause # crash # @@ -460,7 +535,7 @@ while ($i) { dec $i; --connection locker ---error 0,1060 +--error 0,ER_DUP_FIELDNAME ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL; UPDATE t1 SET a=b; @@ -468,11 +543,11 @@ while ($i) { --send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0; --connection locker ---error 0,1091 +--error 0,ER_CANT_DROP_FIELD_OR_KEY ALTER TABLE t1 DROP COLUMN a; --connection writer ---error 0,1054 # unknown column error +--error 0,ER_BAD_FIELD_ERROR # unknown column error --reap } --enable_query_log @@ -485,7 +560,7 @@ while ($i) { dec $i; --connection locker ---error 0,1060 +--error 0,ER_DUP_FIELDNAME ALTER TABLE t1 ADD COLUMN a INT; UPDATE t1 SET a=b; @@ -494,11 +569,11 @@ while ($i) { --send EXECUTE stmt --connection locker ---error 0,1091 +--error 0,ER_CANT_DROP_FIELD_OR_KEY ALTER TABLE t1 DROP COLUMN a; --connection writer ---error 0,1054 # Unknown column 'a' in 'field list' +--error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list' --reap } --enable_query_log @@ -557,7 +632,7 @@ while ($i) { dec $i; --connection locker ---error 0,1060 +--error 0,ER_DUP_FIELDNAME ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL; UPDATE t1 SET a=b; @@ -565,11 +640,11 @@ while ($i) { --send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0; --connection locker ---error 0,1091 +--error 0,ER_CANT_DROP_FIELD_OR_KEY ALTER TABLE t1 DROP COLUMN a; --connection writer ---error 0,1054 # Unknown column 'a' in 'field list' +--error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list' --reap } --enable_query_log @@ -582,7 +657,7 @@ while ($i) { dec $i; --connection locker ---error 0,1060 +--error 0,ER_DUP_FIELDNAME ALTER TABLE t1 ADD COLUMN a INT; UPDATE t1 SET a=b; @@ -591,15 +666,25 @@ while ($i) { --send EXECUTE stmt --connection locker ---error 0,1091 +--error 0,ER_CANT_DROP_FIELD_OR_KEY ALTER TABLE t1 DROP COLUMN a; --connection writer ---error 0,1054 # Unknown column 'a' in 'field list' +--error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list' --reap } --enable_query_log --connection default DROP TABLE t1; + +# Close connections used in many subtests +--disconnect reader +--disconnect locker +--disconnect writer + # End of 5.0 tests + +# Wait till all disconnects are completed +--source include/wait_until_count_sessions.inc + |