diff --git a/mysql-test/suite/tokudb.locks/t/blocking-row-locks-getset.test b/mysql-test/suite/tokudb.locks/t/blocking-row-locks-getset.test new file mode 100644 index 00000000000..e6542825460 --- /dev/null +++ b/mysql-test/suite/tokudb.locks/t/blocking-row-locks-getset.test @@ -0,0 +1,14 @@ +# 9/22/2011 +# Test that blocking row locks work correctly. + +set storage_engine='tokudb'; + +# Make sure we can read/write the global lock timeout system variable +select @@tokudb_lock_timeout; +set global tokudb_lock_timeout=1234567; +select @@tokudb_lock_timeout; +set global tokudb_lock_timeout=5000000; +select @@tokudb_lock_timeout; +# settle on a 2 second timeout going forward +set global tokudb_lock_timeout=1000000; +select @@tokudb_lock_timeout; diff --git a/mysql-test/suite/tokudb.locks/t/blocking-row-locks-rw-conflict.test b/mysql-test/suite/tokudb.locks/t/blocking-row-locks-rw-conflict.test new file mode 100644 index 00000000000..7ddfd92dca7 --- /dev/null +++ b/mysql-test/suite/tokudb.locks/t/blocking-row-locks-rw-conflict.test @@ -0,0 +1,94 @@ +# 9/22/2011 +# Test that blocking row locks work correctly. + +set storage_engine='tokudb'; +set global tokudb_lock_timeout=1000000; + +--disable_warnings +drop table if exists t; +--enable_warnings +create table t (a int primary key, b int); +insert into t values (1, 1); +insert into t values (2, 4); +insert into t values (3, 9); +insert into t values (4, 16); + +set autocommit=off; + +# We need to test that reads/writes properly block when a row lock is +# obtained, so the isolation level needs to be serializable +connect(conn1, localhost, root); +set session transaction isolation level serializable; + +# First test - a point update lock should block a read, but not +# block any others +begin; +select * from t where a=1 for update; + +connect(conn2, localhost, root); +set session transaction isolation level serializable; +# Connection 2 reads, should block until the first connection commits; +# Assert that this call times out with ER_LOCK_WAIT_TIMEOUT +--error ER_LOCK_WAIT_TIMEOUT +select * from t where a=1; +select * from t where a=2; +select * from t where a=3; +select * from t where a=4; + +connection conn1; +commit; + +# Once we commit, it all works; +connection conn2; +select * from t; + +connection conn1; + +# Second test - a range update lock should block a read +begin; +select * from t where a<=2 for update; + +connection conn2; +--error ER_LOCK_WAIT_TIMEOUT +select * from t where a=1; +--error ER_LOCK_WAIT_TIMEOUT +select * from t where a>1; +--error ER_LOCK_WAIT_TIMEOUT +select * from t; +# this should pass, since we locked 1-2 +select * from t where a=4; + +connection conn1; +commit; + +# Once we commit, it works +connection conn2; +select * from t; + +connection conn1; + +# Third test - replace into should do the same +begin; +replace into t values(1, 10),(3,30); + +connection conn2; +--error ER_LOCK_WAIT_TIMEOUT +select * from t where a=1; +--error ER_LOCK_WAIT_TIMEOUT +select * from t where a=3; +select * from t where a=2; +select * from t where a=4; + +connection conn1; +commit; + +# Once we commit, it works +connection conn2; +select * from t; + +connection conn1; +drop table t; + +# TODO: How do I... +# 3.) Assert that some mysql code should return an error (ie: timeout) +# 4.) Have a connection in mysql-test sleep for n seconds