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

52 lines
1.2 KiB
Text
Raw Normal View History

2011-04-25 17:22:25 +02:00
--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'`;
2011-07-14 21:22:41 +02:00
--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;
2011-07-14 21:22:41 +02:00
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'`;
2011-07-14 21:22:41 +02:00
--enable_result_log
let $diff = `SELECT $result - $current`;
2011-07-14 21:22:41 +02:00
echo Deadlocks: $diff;
--echo # Drop test table
drop table t;