mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-33935 fix deadlock counter
- The deadlock counter was moved from Deadlock::find_cycle into Deadlock::report, because the find_cycle method is called multiple times during deadlock detection flow, which means it shouldn't have such side effects. But report() can, which called only once for a victim transaction. - Also the deadlock_detect.test and *.result test case has been extended to handle the fix.
This commit is contained in:
committed by
Marko Mäkelä
parent
ee974ca5e0
commit
5d49a2add7
@ -14,7 +14,14 @@ CREATE TABLE t1(
|
||||
PRIMARY KEY(id)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE dl(
|
||||
id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
|
||||
cnt INT UNSIGNED
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
INSERT INTO t1 VALUES(1), (2), (3);
|
||||
# Preserve the initial value of the deadlock counter
|
||||
INSERT INTO dl(cnt) SELECT variable_value FROM information_schema.global_status WHERE variable_name LIKE 'Innodb_deadlocks';
|
||||
|
||||
# We are not interested query results, only errors
|
||||
--disable_result_log
|
||||
@ -61,6 +68,7 @@ disconnect con2;
|
||||
# and does the update.
|
||||
#
|
||||
connection default;
|
||||
--let $valid_deadlock_cnt= 1
|
||||
if (!$have_deadlock) {
|
||||
--error 0,ER_LOCK_WAIT_TIMEOUT
|
||||
reap;
|
||||
@ -68,12 +76,21 @@ reap;
|
||||
if ($have_deadlock) {
|
||||
--error 0,ER_LOCK_DEADLOCK
|
||||
reap;
|
||||
--disable_query_log
|
||||
INSERT INTO dl(cnt) SELECT variable_value FROM information_schema.global_status WHERE variable_name LIKE 'Innodb_deadlocks';
|
||||
set @init_deadlock_cnt = (SELECT min(k.cnt) FROM dl k);
|
||||
--let $valid_deadlock_cnt= `SELECT (max(t.cnt-@init_deadlock_cnt) = 1) FROM dl t`
|
||||
--enable_query_log
|
||||
}
|
||||
# Indicates that the deadlock counter works well.
|
||||
# Use the default =1 where is no deadlock detection,
|
||||
# to enable unconditional check.
|
||||
--echo 'Deadlock counter is valid';
|
||||
--echo $valid_deadlock_cnt
|
||||
|
||||
ROLLBACK;
|
||||
|
||||
--enable_result_log
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
DROP TABLE dl;
|
||||
--source include/wait_until_count_sessions.inc
|
||||
|
Reference in New Issue
Block a user