Commit a191166c authored by John Esmet's avatar John Esmet

[t:3453] blocking row lock tests, take 1


git-svn-id: file:///svn/mysql/tests/mysql-test@34970 c7de825b-a66e-492c-adef-691d508d4ae1
parent cf2ecdd2
# 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;
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment