set session transaction isolation level serializable;
set session transaction isolation level serializable;
drop table if exists t;
create table t (a int primary key, b int) engine=tokudb;
insert ignore t values(1, 1);
insert ignore t values(2, 4);
insert ignore t values(3, 9);
insert ignore t values(4, 16);
insert ignore t values(5, 25);
insert ignore t values(6, 36);
set global tokudb_lock_timeout=0;
begin;
select * from t where a=1 for update;
a	b
1	1
select * from t where a=1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2 for update;
a	b
2	4
select * from t where a=3 for update;
a	b
3	9
select * from t where a=4 for update;
a	b
4	16
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	4
3	9
4	16
5	25
6	36
commit;
select * from t where a=1 for update;
a	b
1	1
select * from t;
a	b
1	1
2	4
3	9
4	16
5	25
6	36
begin;
select * from t where a=1 for update;
a	b
1	1
update t set b=b where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a=2;
update t set b=b where a=3;
update t set b=b where a=4;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	4
3	9
4	16
5	25
6	36
commit;
update t set b=b where a=1;
select * from t;
a	b
1	1
2	4
3	9
4	16
5	25
6	36
begin;
select * from t where a=1 for update;
a	b
1	1
insert ignore t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert ignore t values(2, 100);
insert ignore t values(3, 100);
insert ignore t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	4
3	9
4	16
5	25
6	36
commit;
insert ignore t values(1, 100);
select * from t;
a	b
1	1
2	4
3	9
4	16
5	25
6	36
begin;
select * from t where a=1 for update;
a	b
1	1
replace t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
replace t values(2, 100);
replace t values(3, 100);
replace t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
replace t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
select * from t where a=1 for update;
a	b
1	100
select * from t where a<=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=0 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>2 for update;
a	b
3	100
4	100
5	25
6	36
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a<=2 for update;
a	b
1	100
2	100
select * from t where a>=0 for update;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
select * from t where a=1 for update;
a	b
1	100
update t set b=b where a<=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=0;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>2;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a<=2;
update t set b=b where a>=0;
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a=1;
select * from t where a=1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2 for update;
a	b
2	100
select * from t where a=3 for update;
a	b
3	100
select * from t where a=4 for update;
a	b
4	100
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a=1 for update;
a	b
1	100
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a=1;
update t set b=b where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a=2;
update t set b=b where a=3;
update t set b=b where a=4;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a=1;
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a=1;
insert ignore t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert ignore t values(2, 100);
insert ignore t values(3, 100);
insert ignore t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
insert ignore t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a=1;
replace t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
replace t values(2, 100);
replace t values(3, 100);
replace t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
replace t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a=1;
select * from t where a<=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=0 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>2 for update;
a	b
3	100
4	100
5	25
6	36
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a<=2 for update;
a	b
1	100
2	100
select * from t where a>=0 for update;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a=1;
update t set b=b where a<=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=0;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>2;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a<=2;
update t set b=b where a>=0;
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
insert ignore t values(1, 100);
select * from t where a=1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2 for update;
a	b
2	100
select * from t where a=3 for update;
a	b
3	100
select * from t where a=4 for update;
a	b
4	100
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a=1 for update;
a	b
1	100
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
insert ignore t values(1, 100);
update t set b=b where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a=2;
update t set b=b where a=3;
update t set b=b where a=4;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a=1;
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
insert ignore t values(1, 100);
insert ignore t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert ignore t values(2, 100);
insert ignore t values(3, 100);
insert ignore t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
insert ignore t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
insert ignore t values(1, 100);
replace t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
replace t values(2, 100);
replace t values(3, 100);
replace t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
replace t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
insert ignore t values(1, 100);
select * from t where a<=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=0 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>2 for update;
a	b
3	100
4	100
5	25
6	36
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a<=2 for update;
a	b
1	100
2	100
select * from t where a>=0 for update;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
insert ignore t values(1, 100);
update t set b=b where a<=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=0;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>2;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a<=2;
update t set b=b where a>=0;
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
replace t values(1, 100);
select * from t where a=1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2 for update;
a	b
2	100
select * from t where a=3 for update;
a	b
3	100
select * from t where a=4 for update;
a	b
4	100
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a=1 for update;
a	b
1	100
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
replace t values(1, 100);
update t set b=b where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a=2;
update t set b=b where a=3;
update t set b=b where a=4;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a=1;
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
replace t values(1, 100);
insert ignore t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert ignore t values(2, 100);
insert ignore t values(3, 100);
insert ignore t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
insert ignore t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
replace t values(1, 100);
replace t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
replace t values(2, 100);
replace t values(3, 100);
replace t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
replace t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
replace t values(1, 100);
select * from t where a<=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=0 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>2 for update;
a	b
3	100
4	100
5	25
6	36
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a<=2 for update;
a	b
1	100
2	100
select * from t where a>=0 for update;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
replace t values(1, 100);
update t set b=b where a<=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=0;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>2;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a<=2;
update t set b=b where a>=0;
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
select * from t where a>=2 and a<=4 for update;
a	b
2	100
3	100
4	100
select * from t where a>=0 and a<=3 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=3 and a<=6 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a<=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=5 for update;
a	b
5	25
6	36
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=3 and a<=5;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=5;
a	b
5	25
6	36
commit;
select * from t where a>=0 and a<=3 for update;
a	b
1	100
2	100
3	100
select * from t where a>=3 and a<=6 for update;
a	b
3	100
4	100
5	25
6	36
select * from t where a<=2 for update;
a	b
1	100
2	100
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
select * from t where a>=2 and a<=4 for update;
a	b
2	100
3	100
4	100
update t set b=b where a>=0 and a<=3;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=3 and a<=6;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a<=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=5;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=3 and a<=5;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=5;
a	b
5	25
6	36
commit;
update t set b=b where a>=0 and a<=3;
update t set b=b where a>=3 and a<=6;
update t set b=b where a<=2;
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a>=2 and a<=4;
select * from t where a>=0 and a<=3 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=3 and a<=6 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a<=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=5 for update;
a	b
5	25
6	36
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=3 and a<=5;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=5;
a	b
5	25
6	36
commit;
select * from t where a>=0 and a<=3 for update;
a	b
1	100
2	100
3	100
select * from t where a>=3 and a<=6 for update;
a	b
3	100
4	100
5	25
6	36
select * from t where a<=2 for update;
a	b
1	100
2	100
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a>=2 and a<=4;
update t set b=b where a>=0 and a<=3;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=3 and a<=6;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a<=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=5;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=3 and a<=5;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=5;
a	b
5	25
6	36
commit;
update t set b=b where a>=0 and a<=3;
update t set b=b where a>=3 and a<=6;
update t set b=b where a<=2;
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
set global tokudb_lock_timeout=500;
begin;
select * from t where a=1 for update;
a	b
1	100
select * from t where a=1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2 for update;
a	b
2	100
select * from t where a=3 for update;
a	b
3	100
select * from t where a=4 for update;
a	b
4	100
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a=1 for update;
a	b
1	100
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
select * from t where a=1 for update;
a	b
1	100
select * from t where a=1 for update;
commit;
a	b
1	100
begin;
select * from t where a=1 for update;
a	b
1	100
update t set b=b where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a=2;
update t set b=b where a=3;
update t set b=b where a=4;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a=1;
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
select * from t where a=1 for update;
a	b
1	100
update t set b=b where a=1;
commit;
begin;
select * from t where a=1 for update;
a	b
1	100
insert ignore t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert ignore t values(2, 100);
insert ignore t values(3, 100);
insert ignore t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
insert ignore t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
select * from t where a=1 for update;
a	b
1	100
insert ignore t values(1, 175);
commit;
begin;
select * from t where a=1 for update;
a	b
1	100
replace t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
replace t values(2, 100);
replace t values(3, 100);
replace t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
replace t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
select * from t where a=1 for update;
a	b
1	100
replace t values(1, 175);
commit;
begin;
select * from t where a=1 for update;
a	b
1	175
select * from t where a<=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=0 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>2 for update;
a	b
3	100
4	100
5	25
6	36
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a<=2 for update;
a	b
1	175
2	100
select * from t where a>=0 for update;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
select * from t;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
begin;
select * from t where a=1 for update;
a	b
1	175
select * from t where a<=2 for update;
commit;
a	b
1	175
2	100
begin;
select * from t where a=1 for update;
a	b
1	175
update t set b=b where a<=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=0;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>2;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a<=2;
update t set b=b where a>=0;
select * from t;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
begin;
select * from t where a=1 for update;
a	b
1	175
update t set b=b where a<=2;
commit;
begin;
update t set b=b where a=1;
select * from t where a=1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2 for update;
a	b
2	100
select * from t where a=3 for update;
a	b
3	100
select * from t where a=4 for update;
a	b
4	100
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a=1 for update;
a	b
1	175
select * from t;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a=1;
select * from t where a=1 for update;
commit;
a	b
1	175
begin;
update t set b=b where a=1;
update t set b=b where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a=2;
update t set b=b where a=3;
update t set b=b where a=4;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a=1;
select * from t;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a=1;
update t set b=b where a=1;
commit;
begin;
update t set b=b where a=1;
insert ignore t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert ignore t values(2, 100);
insert ignore t values(3, 100);
insert ignore t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
insert ignore t values(1, 100);
select * from t;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a=1;
insert ignore t values(1, 175);
commit;
begin;
update t set b=b where a=1;
replace t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
replace t values(2, 100);
replace t values(3, 100);
replace t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
replace t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a=1;
replace t values(1, 175);
commit;
begin;
update t set b=b where a=1;
select * from t where a<=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=0 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>2 for update;
a	b
3	100
4	100
5	25
6	36
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a<=2 for update;
a	b
1	175
2	100
select * from t where a>=0 for update;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
select * from t;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a=1;
select * from t where a<=2 for update;
commit;
a	b
1	175
2	100
begin;
update t set b=b where a=1;
update t set b=b where a<=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=0;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>2;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a<=2;
update t set b=b where a>=0;
select * from t;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a=1;
update t set b=b where a<=2;
commit;
begin;
insert ignore t values(1, 100);
select * from t where a=1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2 for update;
a	b
2	100
select * from t where a=3 for update;
a	b
3	100
select * from t where a=4 for update;
a	b
4	100
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a=1 for update;
a	b
1	175
select * from t;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
begin;
insert ignore t values(1, 150);
select * from t where a=1 for update;
commit;
a	b
1	175
begin;
insert ignore t values(1, 100);
update t set b=b where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a=2;
update t set b=b where a=3;
update t set b=b where a=4;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a=1;
select * from t;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
begin;
insert ignore t values(1, 150);
update t set b=b where a=1;
commit;
begin;
insert ignore t values(1, 100);
insert ignore t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert ignore t values(2, 100);
insert ignore t values(3, 100);
insert ignore t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
insert ignore t values(1, 100);
select * from t;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
begin;
insert ignore t values(1, 150);
insert ignore t values(1, 175);
commit;
begin;
insert ignore t values(1, 100);
replace t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
replace t values(2, 100);
replace t values(3, 100);
replace t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
replace t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
insert ignore t values(1, 150);
replace t values(1, 175);
commit;
begin;
insert ignore t values(1, 100);
select * from t where a<=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=0 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>2 for update;
a	b
3	100
4	100
5	25
6	36
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a<=2 for update;
a	b
1	175
2	100
select * from t where a>=0 for update;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
select * from t;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
begin;
insert ignore t values(1, 150);
select * from t where a<=2 for update;
commit;
a	b
1	175
2	100
begin;
insert ignore t values(1, 100);
update t set b=b where a<=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=0;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>2;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a<=2;
update t set b=b where a>=0;
select * from t;
a	b
1	175
2	100
3	100
4	100
5	25
6	36
begin;
insert ignore t values(1, 150);
update t set b=b where a<=2;
commit;
begin;
replace t values(1, 100);
select * from t where a=1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2 for update;
a	b
2	100
select * from t where a=3 for update;
a	b
3	100
select * from t where a=4 for update;
a	b
4	100
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a=1 for update;
a	b
1	100
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
replace t values(1, 150);
select * from t where a=1 for update;
commit;
a	b
1	150
begin;
replace t values(1, 100);
update t set b=b where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a=2;
update t set b=b where a=3;
update t set b=b where a=4;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a=1;
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
replace t values(1, 150);
update t set b=b where a=1;
commit;
begin;
replace t values(1, 100);
insert ignore t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert ignore t values(2, 100);
insert ignore t values(3, 100);
insert ignore t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
insert ignore t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
replace t values(1, 150);
insert ignore t values(1, 175);
commit;
begin;
replace t values(1, 100);
replace t values(1, 100);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
replace t values(2, 100);
replace t values(3, 100);
replace t values(4, 100);
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
replace t values(1, 100);
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
replace t values(1, 150);
replace t values(1, 175);
commit;
begin;
replace t values(1, 100);
select * from t where a<=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=0 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>2 for update;
a	b
3	100
4	100
5	25
6	36
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
select * from t where a<=2 for update;
a	b
1	100
2	100
select * from t where a>=0 for update;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
replace t values(1, 150);
select * from t where a<=2 for update;
commit;
a	b
1	150
2	100
begin;
replace t values(1, 100);
update t set b=b where a<=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=0;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>2;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=2;
a	b
2	100
3	100
4	100
5	25
6	36
commit;
update t set b=b where a<=2;
update t set b=b where a>=0;
select * from t;
a	b
1	100
2	100
3	100
4	100
5	25
6	36
begin;
replace t values(1, 150);
update t set b=b where a<=2;
commit;
begin;
select * from t where a>=2 and a<=4 for update;
a	b
2	100
3	100
4	100
select * from t where a>=0 and a<=3 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=3 and a<=6 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a<=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=5 for update;
a	b
5	25
6	36
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=3 and a<=5;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=5;
a	b
5	25
6	36
commit;
select * from t where a>=0 and a<=3 for update;
a	b
1	150
2	100
3	100
select * from t where a>=3 and a<=6 for update;
a	b
3	100
4	100
5	25
6	36
select * from t where a<=2 for update;
a	b
1	150
2	100
select * from t;
a	b
1	150
2	100
3	100
4	100
5	25
6	36
begin;
select * from t where a>=2 and a<=4 for update;
a	b
2	100
3	100
4	100
select * from t where a>=0 and a<=3 for update;
commit;
a	b
1	150
2	100
3	100
begin;
select * from t where a>=2 and a<=4 for update;
a	b
2	100
3	100
4	100
update t set b=b where a>=0 and a<=3;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=3 and a<=6;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a<=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=5;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=3 and a<=5;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=5;
a	b
5	25
6	36
commit;
update t set b=b where a>=0 and a<=3;
update t set b=b where a>=3 and a<=6;
update t set b=b where a<=2;
select * from t;
a	b
1	150
2	100
3	100
4	100
5	25
6	36
begin;
select * from t where a>=2 and a<=4 for update;
a	b
2	100
3	100
4	100
update t set b=b where a>=0 and a<=3;
commit;
begin;
update t set b=b where a>=2 and a<=4;
select * from t where a>=0 and a<=3 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=3 and a<=6 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a<=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=5 for update;
a	b
5	25
6	36
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=3 and a<=5;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=5;
a	b
5	25
6	36
commit;
select * from t where a>=0 and a<=3 for update;
a	b
1	150
2	100
3	100
select * from t where a>=3 and a<=6 for update;
a	b
3	100
4	100
5	25
6	36
select * from t where a<=2 for update;
a	b
1	150
2	100
select * from t;
a	b
1	150
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a>=2 and a<=4;
select * from t where a>=0 and a<=3 for update;
commit;
a	b
1	150
2	100
3	100
begin;
update t set b=b where a>=2 and a<=4;
update t set b=b where a>=0 and a<=3;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=3 and a<=6;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a<=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t set b=b where a>=5;
select * from t;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=3 and a<=5;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t where a>=5;
a	b
5	25
6	36
commit;
update t set b=b where a>=0 and a<=3;
update t set b=b where a>=3 and a<=6;
update t set b=b where a<=2;
select * from t;
a	b
1	150
2	100
3	100
4	100
5	25
6	36
begin;
update t set b=b where a>=2 and a<=4;
update t set b=b where a>=0 and a<=3;
commit;
drop table t;
set global tokudb_lock_timeout=4000;