生产上偶现这段代码会出现死锁,死锁日志如下。
*** (1) TRANSACTION:
TRANSACTION 424487272, ACTIVE 0 sec fetching rows
mysql tables in use 3, locked 3
LOCK WAIT 6 lock struct(s), heap size 1184, 4 row lock(s)
MySQL thread id 3205005, OS thread handle 0x7f39c21c8700, query id 567774892 10.14.34.30 finance Searching rows for update
update repay_plan_info_1
SET actual_pay_period_amount = 38027,
actual_pay_principal_amount = 36015,
actual_pay_interest_amount = 1980,
actual_pay_fee = 0,
actual_pay_fine = 32,
actual_discount_amount = 0,
repay_status = 'PAYOFF',
repay_type = 'OVERDUE',
actual_repay_time = '2019-08-12 15:48:15.025'
WHERE ( user_id = '938467411690006528'
and loan_order_no = 'LN201907120655461690006528458116'
and seq_no = 1
and repay_status <> 'PAYOFF' )
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 3680 page no 30 n bits 136 index `PRIMARY` of table `db_loan_core_2`.`repay_plan_info_1` trx id 424487272 lock_mode X locks rec but not gap waiting
Record lock, heap no 64 PHYSICAL RECORD: n_fields 33; compact format; info bits 0
0: len 8; hex 800000000000051e; asc ;;
1: len 6; hex 0000193d35df; asc =5 ;;
2: len 7; hex 06000001d402e7; asc ;;
3: len 30; hex 323031393036313332303532303634323936303534323130353730303030; asc 201906132052064296054210570000; (total 32 bytes);
4: len 30; hex 4c4e32303139303631333031323934303136393030303635323831373534; asc LN2019061301294016900065281754; (total 32 bytes);
5: len 4; hex 80000002; asc ;;
6: len 18; hex 393338343637343131363930303036353238; asc 938467411690006528;;
7: len 4; hex 80000003; asc ;;
8: len 4; hex 80000258; asc X;;
9: len 3; hex 646179; asc day;;
10: SQL NULL;
11: SQL NULL;
12: len 8; hex 8000000000005106; asc Q ;;
13: len 8; hex 8000000000000000; asc ;;
14: len 8; hex 8000000000004e1e; asc N ;;
15: len 8; hex 8000000000000000; asc ;;
16: len 8; hex 80000000000002d6; asc ;;
17: len 8; hex 8000000000000000; asc ;;
18: len 8; hex 8000000000000000; asc ;;
19: len 8