@aliasliyu4
2018-04-03T19:13:31.000000Z
字数 387
阅读 1105
在工作中有时候是会碰到死锁这类情况的,如何故意的去测试死锁其实也是很简单的事情。文不如表。
CREATE TABLE `innodb_deadlock_maker` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
insert into innodb_deadlock_maker(a) values (0), (1);
run transaction one session:
start transaction;
update innodb_deadlock_maker set a = 0 where a <0>;
run transaction other session:
start transaction;
update innodb_deadlock_maker set a = 1 where a <1>;
开始操作吧: