$ mysqld-debug --user=mysql& root@(none) 16:36: set global innodb_purge_stop_now=1;
数据库中存在如下数据表,A列为主键,B列为唯一索引,隔离级别为RC
root@test 16:25: desc z; +-------+------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------+------+-----+---------+-------+ | a | int | NO | PRI | NULL | | | b | int | YES | UNI | NULL | | +-------+------+------+-----+---------+-------+
LATEST DETECTED DEADLOCK ------------------------ 2020-05-31 16:53:04 0x7f4af9c67700 *** (1) TRANSACTION: TRANSACTION 6303, ACTIVE 77 sec inserting mysql tables in use 1, locked 1 LOCK WAIT 4 lock struct(s), heap size 1160, 4 row lock(s), undo log entries 2 MySQL thread id 81, OS thread handle 139959995107072, query id 150 localhost root update insert into z values(10,45) *** (1) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 31 page no 4 n bits 80 index b of table `test`.`z` trx id 6303 lock_mode X locks gap before rec insert intention waiting Record lock, heap no 6 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 0: len 4; hex 80000032; asc 2;; 1: len 4; hex 80000005; asc ;;
*** (2) TRANSACTION: TRANSACTION 6308, ACTIVE 69 sec inserting, thread declared inside InnoDB 5000 mysql tables in use 1, locked 1 4 lock struct(s), heap size 1160, 5 row lock(s), undo log entries 2 MySQL thread id 88, OS thread handle 139959994840832, query id 152 localhost root update insert into z values(11,25) *** (2) HOLDS THE LOCK(S): RECORD LOCKS space id 31 page no 4 n bits 80 index b of table `test`.`z` trx id 6308 lock mode S Record lock, heap no 5 PHYSICAL RECORD: n_fields 2; compact format; info bits 32 0: len 4; hex 80000028; asc (;; 1: len 4; hex 80000004; asc ;;
Record lock, heap no 6 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 0: len 4; hex 80000032; asc 2;; 1: len 4; hex 80000005; asc ;;
Record lock, heap no 7 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 0: len 4; hex 8000003c; asc <;; 1: len 4; hex 80000006; asc ;;
*** (2) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 31 page no 4 n bits 80 index b of table `test`.`z` trx id 6308 lock_mode X locks gap before rec insert intention waiting Record lock, heap no 4 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 0: len 4; hex 8000001e; asc ;; 1: len 4; hex 80000003; asc ;;