mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
8ff1096999
The issue is that trx_t::lock.was_chosen_as_deadlock_victim can be reset
before the transaction check it and set trx_t::error_state.
The fix is to reset trx_t::lock.was_chosen_as_deadlock_victim only in
trx_t::commit_in_memory(), which is invoked on full rollback. There is
also no need to have separate bit in
trx_t::lock.was_chosen_as_deadlock_victim to flag transaction it was
chosen as a victim of Galera conflict resolution, the same variable can be
used for both cases except debug build. For debug build we need to
distinguish deadlock and Galera's abort victims for debug checks. Also
there is no need to check for deadlock in lock_table_enqueue_waiting() for
Galera as the coresponding check presents in lock_wait().
Local variable "error_state" in lock_wait() was replaced with
trx->error_state, because before the replace
lock_sys_t::cancel<false>(trx, lock) and lock_sys.deadlock_check() could
change trx->error_state, which then could be overwritten with the local
"error_state" variable value.
The lock_wait_suspend_thread_enter DEBUG_SYNC point name is misleading,
because lock_wait_suspend_thread was eliminated in e71e613
. It was renamed
to lock_wait_start.
Reviewed by: Marko Mäkelä, Jan Lindström.
221 lines
5.8 KiB
Text
221 lines
5.8 KiB
Text
--source include/have_innodb.inc
|
|
--source include/have_debug.inc
|
|
--source include/have_debug_sync.inc
|
|
|
|
# Save the initial number of concurrent sessions
|
|
--source include/count_sessions.inc
|
|
|
|
--echo #
|
|
--echo # Bug #18451287 REDUNDANT DELETE MARKING AFTER DB_LOCK_WAIT
|
|
--echo #
|
|
|
|
create table t1 (f1 int primary key, f2 blob) engine=innodb;
|
|
create table t2 (f1 int primary key, f2 int,
|
|
foreign key (f2) references t1(f1) on update cascade) engine=innodb;
|
|
|
|
show create table t1;
|
|
show create table t2;
|
|
insert into t1 values (1, repeat('+', 20000));
|
|
insert into t1 values (2, repeat('-', 20000));
|
|
insert into t1 values (3, repeat('=', 20000));
|
|
insert into t2 values (1, 2);
|
|
|
|
select f1, right(f2, 20) as p2 from t1;
|
|
select f1, f2 from t2;
|
|
|
|
connect(con1,localhost,root,,test);
|
|
start transaction;
|
|
select f1, f2 from t2 for update;
|
|
|
|
connection default;
|
|
set debug_sync='lock_wait_start SIGNAL upd_waiting WAIT_FOR go_upd';
|
|
send update t1 set f1 = 10 where f1 = 2;
|
|
|
|
connection con1;
|
|
set debug_sync='now WAIT_FOR upd_waiting';
|
|
rollback;
|
|
set debug_sync='now SIGNAL go_upd';
|
|
|
|
connection default;
|
|
--echo # reap: update t1 set f1 = 10 where f1 = 2;
|
|
reap;
|
|
|
|
select f1, right(f2, 20) as p2 from t1;
|
|
select f1, f2 from t2;
|
|
|
|
drop table t2, t1;
|
|
|
|
set debug_sync = reset;
|
|
|
|
--echo #
|
|
--echo # Test Scenario: Two tables t1 -> t2 are involved in update cascade.
|
|
--echo # If DB_LOCK_WAIT happens when t1 is being updated and FK constraints
|
|
--echo # are being checked in t2, then retry must happen on t1. The update
|
|
--echo # cascade happens in secondary index. For secondary index testing,
|
|
--echo # blobs are not needed.
|
|
--echo #
|
|
|
|
create table t1 (f1 int primary key, f2 int, key k1(f2)) engine=innodb;
|
|
create table t2 (f1 int primary key, f2 int,
|
|
foreign key (f2) references t1(f2) on update cascade) engine=innodb;
|
|
|
|
show create table t1;
|
|
show create table t2;
|
|
insert into t1 values (1, 91);
|
|
insert into t2 values (1, 91);
|
|
|
|
select f1, f2 from t1;
|
|
select f1, f2 from t2;
|
|
|
|
connection con1;
|
|
start transaction;
|
|
select f1, f2 from t2 for update;
|
|
|
|
connection default;
|
|
set debug_sync='lock_wait_start SIGNAL upd_waiting WAIT_FOR go_upd';
|
|
send update t1 set f2 = 28 where f2 = 91;
|
|
|
|
connection con1;
|
|
set debug_sync='now WAIT_FOR upd_waiting';
|
|
rollback;
|
|
set debug_sync='now SIGNAL go_upd';
|
|
|
|
connection default;
|
|
--echo # reap: update t1 set f1 = 10 where f1 = 2;
|
|
--reap
|
|
|
|
select f1, f2 from t1;
|
|
select f1, f2 from t2;
|
|
|
|
drop table t2, t1;
|
|
|
|
set debug_sync = reset;
|
|
|
|
--echo #
|
|
--echo # Test Scenario: Three tables t1 -> t2 -> t3 are involved in update cascade.
|
|
--echo # If DB_LOCK_WAIT happens when t2 is being updated, then retry must happen
|
|
--echo # on t2.
|
|
--echo #
|
|
|
|
create table t1 (f1 int primary key, f2 blob) engine=innodb;
|
|
create table t2 (f1 int primary key, f2 blob,
|
|
foreign key (f1) references t1(f1) on update cascade) engine=innodb;
|
|
create table t3 (f1 int primary key, f2 blob,
|
|
foreign key (f1) references t2(f1) on update cascade) engine=innodb;
|
|
|
|
show create table t1;
|
|
show create table t2;
|
|
show create table t3;
|
|
|
|
insert into t1 values (2, repeat('-', 20000));
|
|
insert into t2 values (2, repeat('%', 20000));
|
|
insert into t3 values (2, repeat('+', 20000));
|
|
|
|
select f1, right(f2, 20) as p2 from t1;
|
|
select f1, right(f2, 20) as p2 from t2;
|
|
select f1, right(f2, 20) as p2 from t3;
|
|
|
|
connection con1;
|
|
start transaction;
|
|
select f1 from t3 for update;
|
|
|
|
connection default;
|
|
set debug_sync='lock_wait_start SIGNAL upd_waiting WAIT_FOR go_upd';
|
|
send update t1 set f1 = 10 where f1 = 2;
|
|
|
|
connection con1;
|
|
set debug_sync='now WAIT_FOR upd_waiting';
|
|
rollback;
|
|
|
|
--echo # The table t1 is updated.
|
|
--echo # In t2 delete-mark happened. Retry will happen on t2.
|
|
--echo # In t3 yet to be updated.
|
|
set session transaction isolation level read uncommitted;
|
|
start transaction;
|
|
select f1, right(f2, 20) as p2 from t1;
|
|
select f1, right(f2, 20) as p2 from t2;
|
|
select f1, right(f2, 20) as p2 from t3;
|
|
commit;
|
|
|
|
set debug_sync='now SIGNAL go_upd';
|
|
|
|
connection default;
|
|
--echo # reap: update t1 set f1 = 10 where f1 = 2;
|
|
--reap;
|
|
|
|
start transaction;
|
|
select f1, right(f2, 20) as p2 from t1;
|
|
select f1, right(f2, 20) as p2 from t2;
|
|
select f1, right(f2, 20) as p2 from t3;
|
|
commit;
|
|
|
|
drop table t3, t2, t1;
|
|
|
|
set debug_sync = reset;
|
|
|
|
--echo #
|
|
--echo # Test Scenario: Three tables t1 -> t2 -> t3 are involved in update
|
|
--echo # cascade. If DB_LOCK_WAIT happens when t2 is being updated, then
|
|
--echo # retry must happen on t2. The update cascade is happening via
|
|
--echo # secondary index (hence blobs are not needed).
|
|
--echo #
|
|
|
|
create table t1 (f1 int primary key, f2 int, key k1(f2)) engine=innodb;
|
|
create table t2 (f1 int primary key, f2 int,
|
|
foreign key (f2) references t1(f2) on update cascade) engine=innodb;
|
|
create table t3 (f1 int primary key, f2 int,
|
|
foreign key (f2) references t2(f2) on update cascade) engine=innodb;
|
|
|
|
show create table t1;
|
|
show create table t2;
|
|
show create table t3;
|
|
|
|
insert into t1 values (2, 91);
|
|
insert into t2 values (2, 91);
|
|
insert into t3 values (2, 91);
|
|
|
|
select f1, f2 from t1;
|
|
select f1, f2 from t2;
|
|
select f1, f2 from t3;
|
|
|
|
connection con1;
|
|
start transaction;
|
|
select f1 from t3 for update;
|
|
|
|
connection default;
|
|
set debug_sync='lock_wait_start SIGNAL upd_waiting WAIT_FOR go_upd';
|
|
send update t1 set f2 = 28 where f2 = 91;
|
|
|
|
connection con1;
|
|
set debug_sync='now WAIT_FOR upd_waiting';
|
|
rollback;
|
|
|
|
--echo # The table t1 is updated.
|
|
--echo # In t2 delete-mark happened. Retry will happen on t2.
|
|
--echo # In t3 yet to be updated.
|
|
set session transaction isolation level read uncommitted;
|
|
start transaction;
|
|
select f1, f2 from t1;
|
|
select f1, f2 from t2;
|
|
select f1, f2 from t3;
|
|
commit;
|
|
|
|
set debug_sync='now SIGNAL go_upd';
|
|
disconnect con1;
|
|
|
|
connection default;
|
|
--echo # reap: update t1 set f2 = 28 where f2 = 91;
|
|
--reap;
|
|
|
|
start transaction;
|
|
select f1, f2 from t1;
|
|
select f1, f2 from t2;
|
|
select f1, f2 from t3;
|
|
commit;
|
|
|
|
drop table t3, t2, t1;
|
|
|
|
set debug_sync = reset;
|
|
|
|
# Wait till all disconnects are completed
|
|
--source include/wait_until_count_sessions.inc
|