mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 17:33:44 +01:00
Set an error code when a deadlock occurs in semi-consistent read. (Bug #31494)
innodb-semi-consistent: New tests for InnoDB semi-consistent reads. Unfortunately, these will not trigger Bug #31494, because there merely occur lock wait timeouts, not deadlocks.
This commit is contained in:
parent
96fc36b9cf
commit
62e98cd050
4 changed files with 84 additions and 0 deletions
1
mysql-test/innodb-semi-consistent-master.opt
Normal file
1
mysql-test/innodb-semi-consistent-master.opt
Normal file
|
@ -0,0 +1 @@
|
|||
--innodb_locks_unsafe_for_binlog=true --innodb_lock_wait_timeout=2
|
36
mysql-test/innodb-semi-consistent.result
Normal file
36
mysql-test/innodb-semi-consistent.result
Normal file
|
@ -0,0 +1,36 @@
|
|||
set session transaction isolation level read committed;
|
||||
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
|
||||
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
|
||||
set autocommit=0;
|
||||
select * from t1 where a=3 lock in share mode;
|
||||
a
|
||||
3
|
||||
set session transaction isolation level read committed;
|
||||
set autocommit=0;
|
||||
update t1 set a=10 where a=5;
|
||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||
commit;
|
||||
update t1 set a=10 where a=5;
|
||||
select * from t1 where a=2 for update;
|
||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||
select * from t1 where a=2 limit 1 for update;
|
||||
a
|
||||
2
|
||||
update t1 set a=11 where a=6;
|
||||
update t1 set a=12 where a=2;
|
||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||
update t1 set a=13 where a=1;
|
||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||
commit;
|
||||
update t1 set a=14 where a=1;
|
||||
commit;
|
||||
select * from t1;
|
||||
a
|
||||
14
|
||||
2
|
||||
3
|
||||
4
|
||||
10
|
||||
11
|
||||
7
|
||||
drop table t1;
|
46
mysql-test/innodb-semi-consistent.test
Normal file
46
mysql-test/innodb-semi-consistent.test
Normal file
|
@ -0,0 +1,46 @@
|
|||
-- source include/not_embedded.inc
|
||||
-- source include/have_innodb.inc
|
||||
|
||||
# basic tests of semi-consistent reads
|
||||
|
||||
connect (a,localhost,root,,);
|
||||
connect (b,localhost,root,,);
|
||||
connection a;
|
||||
set session transaction isolation level read committed;
|
||||
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
|
||||
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
|
||||
set autocommit=0;
|
||||
# this should lock the entire table
|
||||
select * from t1 where a=3 lock in share mode;
|
||||
connection b;
|
||||
set session transaction isolation level read committed;
|
||||
set autocommit=0;
|
||||
-- error ER_LOCK_WAIT_TIMEOUT
|
||||
update t1 set a=10 where a=5;
|
||||
connection a;
|
||||
commit;
|
||||
connection b;
|
||||
update t1 set a=10 where a=5;
|
||||
connection a;
|
||||
-- error ER_LOCK_WAIT_TIMEOUT
|
||||
select * from t1 where a=2 for update;
|
||||
# this should lock the records (1),(2)
|
||||
select * from t1 where a=2 limit 1 for update;
|
||||
connection b;
|
||||
update t1 set a=11 where a=6;
|
||||
-- error ER_LOCK_WAIT_TIMEOUT
|
||||
update t1 set a=12 where a=2;
|
||||
-- error ER_LOCK_WAIT_TIMEOUT
|
||||
update t1 set a=13 where a=1;
|
||||
connection a;
|
||||
commit;
|
||||
connection b;
|
||||
update t1 set a=14 where a=1;
|
||||
commit;
|
||||
connection a;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
connection default;
|
||||
disconnect a;
|
||||
disconnect b;
|
|
@ -4003,6 +4003,7 @@ no_gap_lock:
|
|||
mutex_enter(&kernel_mutex);
|
||||
if (trx->was_chosen_as_deadlock_victim) {
|
||||
mutex_exit(&kernel_mutex);
|
||||
err = DB_DEADLOCK;
|
||||
|
||||
goto lock_wait_or_error;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue