Commit cd6ad0a1 authored by Rich Prohaska's avatar Rich Prohaska

#3497 tests for update and delete deadlocks, as well as the select for update refs[t:3497]

git-svn-id: file:///svn/mysql/tests/mysql-test@31573 c7de825b-a66e-492c-adef-691d508d4ae1
parent c96e822c
set storage_engine='tokudb';
drop table if exists t;
create table t (a int primary key, b int);
insert into t values (1,0),(2,1),(3,0);
set tokudb_use_write_locks=1;
begin;
delete from t where b>0;
set transaction isolation level serializable;
select * from t where a!=2;
commit;
a b
1 0
3 0
drop table t;
set storage_engine='tokudb';
drop table if exists t;
create table t (a int primary key, b int);
insert into t values (1,0);
set tokudb_use_write_locks=1;
set session transaction isolation level repeatable read;
begin;
select * from t where a=1 for update;
a b
1 0
update t set b=b+1 where a=1;
set tokudb_use_write_locks=1;
set session transaction isolation level repeatable read;
begin;
select * from t where a=1 for update;
commit;
a b
1 1
update t set b=b+1 where a=1;
select * from t;
a b
1 2
commit;
drop table t;
set storage_engine='tokudb';
drop table if exists t;
create table t (a int primary key, b int);
insert into t values (1,0);
set tokudb_use_write_locks=1;
set session transaction isolation level serializable;
begin;
select * from t where a=1 for update;
a b
1 0
update t set b=b+1 where a=1;
set tokudb_use_write_locks=1;
set session transaction isolation level serializable;
begin;
select * from t where a=1 for update;
commit;
a b
1 1
update t set b=b+1 where a=1;
select * from t;
a b
1 2
commit;
drop table t;
set storage_engine='tokudb';
drop table if exists t;
create table t (a int primary key, b int);
insert into t values (1,0);
set tokudb_use_write_locks=1;
set session transaction isolation level read committed;
begin;
select * from t where a=1 for update;
a b
1 0
update t set b=b+1 where a=1;
set tokudb_use_write_locks=1;
set session transaction isolation level read committed;
begin;
select * from t where a=1 for update;
commit;
a b
1 1
update t set b=b+1 where a=1;
select * from t;
a b
1 2
commit;
drop table t;
set storage_engine='tokudb';
drop table if exists t;
create table t (a int primary key, b int);
insert into t values (1,0),(2,1),(3,0);
set tokudb_use_write_locks=1;
begin;
update t set b=b+1 where b>0;
set transaction isolation level serializable;
select * from t where a!=2;
commit;
a b
1 0
3 0
drop table t;
set storage_engine='tokudb';
--disable_warnings
drop table if exists t;
--enable_warnings
connect(conn1,localhost);
connection default;
create table t (a int primary key, b int);
insert into t values (1,0),(2,1),(3,0);
set tokudb_use_write_locks=1;
begin;
delete from t where b>0;
connection conn1;
set transaction isolation level serializable;
send select * from t where a!=2;
connection default;
commit;
connection conn1;
reap;
connection default;
disconnect conn1;
drop table t;
# test that select for update is executed with serializable isolation
set storage_engine='tokudb';
--disable_warnings
drop table if exists t;
--enable_warnings
create table t (a int primary key, b int);
insert into t values (1,0);
set tokudb_use_write_locks=1;
set session transaction isolation level repeatable read;
begin;
# t1 select for update
select * from t where a=1 for update;
# t2 update
update t set b=b+1 where a=1;
connect(conn1,localhost);
set tokudb_use_write_locks=1;
set session transaction isolation level repeatable read;
begin;
# t2 select for update, should hang until t1 commits
send select * from t where a=1 for update;
connection default;
# t1 commit
commit;
connection conn1;
# t2 select for update returns
reap;
# t2 update
update t set b=b+1 where a=1;
select * from t;
commit;
connection default;
disconnect conn1;
drop table t;
# test that select for update is executed with serializable isolation
set storage_engine='tokudb';
--disable_warnings
drop table if exists t;
--enable_warnings
create table t (a int primary key, b int);
insert into t values (1,0);
set tokudb_use_write_locks=1;
set session transaction isolation level serializable;
begin;
# t1 select for update
select * from t where a=1 for update;
# t2 update
update t set b=b+1 where a=1;
connect(conn1,localhost);
set tokudb_use_write_locks=1;
set session transaction isolation level serializable;
begin;
# t2 select for update, should hang until t1 commits
send select * from t where a=1 for update;
connection default;
# t1 commit
commit;
connection conn1;
# t2 select for update returns
reap;
# t2 update
update t set b=b+1 where a=1;
select * from t;
commit;
connection default;
disconnect conn1;
drop table t;
# test that select for update is executed with serializable isolation
set storage_engine='tokudb';
--disable_warnings
drop table if exists t;
--enable_warnings
create table t (a int primary key, b int);
insert into t values (1,0);
set tokudb_use_write_locks=1;
set session transaction isolation level read committed;
begin;
# t1 select for update
select * from t where a=1 for update;
# t2 update
update t set b=b+1 where a=1;
connect(conn1,localhost);
set tokudb_use_write_locks=1;
set session transaction isolation level read committed;
begin;
# t2 select for update, should hang until t1 commits
send select * from t where a=1 for update;
connection default;
# t1 commit
commit;
connection conn1;
# t2 select for update returns
reap;
# t2 update
update t set b=b+1 where a=1;
select * from t;
commit;
connection default;
disconnect conn1;
drop table t;
# test that update only take write locks when tokudb_use_write_locks is asserted
# t1 scans all of the rows in a table and updates 1 of them
# t1 grabs a write range lock on -infinity +infinity
# t2 scans all of the rows in a table except the one updated by t1
# t2 should hang until t1 commits
set storage_engine='tokudb';
--disable_warnings
drop table if exists t;
--enable_warnings
connect(conn1,localhost);
connection default;
create table t (a int primary key, b int);
insert into t values (1,0),(2,1),(3,0);
set tokudb_use_write_locks=1;
begin;
update t set b=b+1 where b>0;
connection conn1;
set transaction isolation level serializable;
send select * from t where a!=2;
connection default;
commit;
connection conn1;
reap;
connection default;
disconnect conn1;
drop table t;
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