mirror of
https://github.com/MariaDB/server.git
synced 2025-02-01 11:31:51 +01:00
#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
This commit is contained in:
parent
c96e822c99
commit
cd6ad0a15d
10 changed files with 272 additions and 0 deletions
14
mysql-test/suite/tokudb.locks/r/delete-deadlock-1.result
Normal file
14
mysql-test/suite/tokudb.locks/r/delete-deadlock-1.result
Normal file
|
@ -0,0 +1,14 @@
|
|||
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;
|
24
mysql-test/suite/tokudb.locks/r/select-update-1.result
Normal file
24
mysql-test/suite/tokudb.locks/r/select-update-1.result
Normal file
|
@ -0,0 +1,24 @@
|
|||
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;
|
24
mysql-test/suite/tokudb.locks/r/select-update-2.result
Normal file
24
mysql-test/suite/tokudb.locks/r/select-update-2.result
Normal file
|
@ -0,0 +1,24 @@
|
|||
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;
|
24
mysql-test/suite/tokudb.locks/r/select-update-3.result
Normal file
24
mysql-test/suite/tokudb.locks/r/select-update-3.result
Normal file
|
@ -0,0 +1,24 @@
|
|||
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;
|
14
mysql-test/suite/tokudb.locks/r/update-deadlock-1.result
Normal file
14
mysql-test/suite/tokudb.locks/r/update-deadlock-1.result
Normal file
|
@ -0,0 +1,14 @@
|
|||
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;
|
29
mysql-test/suite/tokudb.locks/t/delete-deadlock-1.test
Normal file
29
mysql-test/suite/tokudb.locks/t/delete-deadlock-1.test
Normal file
|
@ -0,0 +1,29 @@
|
|||
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;
|
36
mysql-test/suite/tokudb.locks/t/select-update-1.test
Normal file
36
mysql-test/suite/tokudb.locks/t/select-update-1.test
Normal file
|
@ -0,0 +1,36 @@
|
|||
# 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;
|
||||
|
36
mysql-test/suite/tokudb.locks/t/select-update-2.test
Normal file
36
mysql-test/suite/tokudb.locks/t/select-update-2.test
Normal file
|
@ -0,0 +1,36 @@
|
|||
# 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;
|
||||
|
36
mysql-test/suite/tokudb.locks/t/select-update-3.test
Normal file
36
mysql-test/suite/tokudb.locks/t/select-update-3.test
Normal file
|
@ -0,0 +1,36 @@
|
|||
# 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;
|
||||
|
35
mysql-test/suite/tokudb.locks/t/update-deadlock-1.test
Normal file
35
mysql-test/suite/tokudb.locks/t/update-deadlock-1.test
Normal file
|
@ -0,0 +1,35 @@
|
|||
# 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;
|
Loading…
Add table
Reference in a new issue