mariadb/mysql-test/suite/percona/percona_innodb_deadlock_count.test

51 lines
1.2 KiB
Text

--source include/have_xtradb.inc
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connect (con3,localhost,root,,);
--echo # Drop test table
--disable_warnings
drop table if exists t;
--enable_warnings
--echo # Create test table
create table t(a INT PRIMARY KEY, b INT) engine=InnoDB;
--echo # Insert two rows to test table
insert into t values(2,1);
insert into t values(1,2);
#--echo # Save current deadlock count
let $current = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_deadlocks'`;
--disable_result_log
connection con1;
BEGIN; SELECT b FROM t WHERE a=1 FOR UPDATE;
connection con2;
BEGIN; SELECT b FROM t WHERE a=2 FOR UPDATE;
connection con1;
SEND SELECT b FROM t WHERE a=2 FOR UPDATE;
connection con2;
SEND SELECT b FROM t WHERE a=1 FOR UPDATE;
connection con1;
--error 0, ER_LOCK_DEADLOCK
reap;
ROLLBACK;
connection con2;
--error 0, ER_LOCK_DEADLOCK
reap;
ROLLBACK;
connection con3;
let $result = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_deadlocks'`;
--enable_result_log
let $diff = `SELECT $result - $current`;
echo Deadlocks: $diff;
--echo # Drop test table
drop table t;