mirror of
https://github.com/MariaDB/server.git
synced 2025-01-21 06:22:28 +01:00
[t:3453] blocking row lock tests, take 1
git-svn-id: file:///svn/mysql/tests/mysql-test@34970 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
cf2ecdd201
commit
a191166c7b
2 changed files with 108 additions and 0 deletions
|
@ -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;
|
|
@ -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
|
Loading…
Reference in a new issue