Code:
2017-02-20 19:27:00 7f63cfed3700
*** (1) TRANSACTION:
TRANSACTION 37905831, ACTIVE 1 sec inserting
mysql tables in use 1, locked 1
LOCK WAIT 3 lock struct(s), heap size 360, 2 row lock(s), undo log entries 1
MySQL thread id 278944, OS thread handle 0x7f64ef8ac700, query id 783589246 localhost xxx update
INSERT INTO `vw_permission` (`applytypeid`, `applyid`, `nodetypeid`, `nodeid`, `applykey`, `bitvalue`) VALUES (?, ?, ?, ?, ?, ?)
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 2554 page no 4 n bits 128 index `race_condition` of table `xxx_xxx`.`vw_permission` trx id 37905831 lock mode S waiting
*** (2) TRANSACTION:
TRANSACTION 37905828, ACTIVE 2 sec fetching rows, thread declared inside InnoDB 4941
mysql tables in use 1, locked 1
1443 lock struct(s), heap size 161320, 241754 row lock(s), undo log entries 240258
MySQL thread id 278943, OS thread handle 0x7f63cfed3700, query id 783589249 localhost xxx updating
DELETE FROM `vw_permission` WHERE applytypeid = 0 AND applyid <> 0
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 2554 page no 4 n bits 128 index `race_condition` of table `xxx_xxx`.`vw_permission` trx id 37905828 lock_mode X locks rec but not gap
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 2554 page no 13 n bits 80 index `PRIMARY` of table `xxx_xxx`.`vw_permission` trx id 37905828 lock_mode X waiting
*** WE ROLL BACK TRANSACTION (1)