1
drop table if exists t1;
2
SET @orig_lock_wait_timeout= @@innodb_lock_wait_timeout;
3
SET GLOBAL innodb_lock_wait_timeout=2;
4
set session transaction isolation level read committed;
5
create table t1(a int not null) engine=innodb;
6
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
8
select * from t1 where a=3 lock in share mode;
11
set session transaction isolation level read committed;
13
update t1 set a=10 where a=5;
15
update t1 set a=10 where a=5;
16
select * from t1 where a=2 for update;
17
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
18
select * from t1 where a=2 limit 1 for update;
21
update t1 set a=11 where a=6;
22
update t1 set a=12 where a=2;
23
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
24
update t1 set a=13 where a=1;
26
update t1 set a=14 where a=1;
38
SET GLOBAL innodb_lock_wait_timeout=@orig_lock_wait_timeout ;