生产上偶现这段代码会出现死锁,死锁日志如下 。
*** (1) TRANSACTION:TRANSACTION 424487272, ACTIVE 0 sec fetching rowsMySQL tables in use 3, locked 3LOCK 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 updateupdate repay_plan_info_1SET 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 = 1and 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 waitingRecord 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; ascX;; 9: len 3; hex 646179; asc day;; 10: SQL NULL; 11: SQL NULL; 12: len 8; hex 8000000000005106; ascQ ;; 13: len 8; hex 8000000000000000; asc;; 14: len 8; hex 8000000000004e1e; ascN ;; 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; hex 8000000000000000; asc;; 20: len 8; hex 8000000000000012; asc;; 21: len 8; hex 8000000000000000; asc;; 22: len 8; hex 8000000000000000; asc;; 23: len 8; hex 8000000000000000; asc;; 24: len 8; hex 3230313930383131; asc 20190811;; 25: len 7; hex 4f564552445545; asc OVERDUE;; 26: SQL NULL; 27: len 1; hex 59; asc Y;; 28: SQL NULL; 29: len 5; hex 99a35a1768; ascZ h;; 30: len 4; hex 5d503dd8; asc ]P= ;; 31: SQL NULL; 32: len 5; hex 99a3d80281; asc;;*** (2) TRANSACTION:TRANSACTION 424487271, ACTIVE 0 sec fetching rowsmysql tables in use 3, locked 35 lock struct(s), heap size 1184, 3 row lock(s)MySQL thread id 3204980, OS thread handle 0x7f3db0cf6700, query id 567774893 10.14.34.30 finance Searching rows for updateupdate repay_plan_info_1SET actual_pay_period_amount = 20742,actual_pay_principal_amount = 19998,actual_pay_interest_amount = 726,actual_pay_fee = 0,actual_pay_fine = 18,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 = 'LN201906130129401690006528175485'and seq_no = 2and repay_status <> 'PAYOFF' )*** (2) HOLDS THE LOCK(S):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 424487271 lock_mode X locks rec but not gapRecord 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; ascX;; 9: len 3; hex 646179; asc day;; 10: SQL NULL; 11: SQL NULL; 12: len 8; hex 8000000000005106; ascQ ;; 13: len 8; hex 8000000000000000; asc;; 14: len 8; hex 8000000000004e1e; ascN ;; 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; hex 8000000000000000; asc;; 20: len 8; hex 8000000000000012; asc;; 21: len 8; hex 8000000000000000; asc;; 22: len 8; hex 8000000000000000; asc;; 23: len 8; hex 8000000000000000; asc;; 24: len 8; hex 3230313930383131; asc 20190811;; 25: len 7; hex 4f564552445545; asc OVERDUE;; 26: SQL NULL; 27: len 1; hex 59; asc Y;; 28: SQL NULL; 29: len 5; hex 99a35a1768; ascZ h;; 30: len 4; hex 5d503dd8; asc ]P= ;; 31: SQL NULL; 32: len 5; hex 99a3d80281; asc;;*** (2) WAITING FOR THIS LOCK TO BE GRANTED:RECORD LOCKS space id 3680 page no 137 n bits 464 index `idx_user_id` of table `db_loan_core_2`.`repay_plan_info_1` trx id 424487271 lock_mode X locks rec but not gap waitingRecord lock, heap no 161 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 0: len 18; hex 393338343637343131363930303036353238; asc 938467411690006528;; 1: len 8; hex 800000000000051e; asc;;*** WE ROLL BACK TRANSACTION (2)
推荐阅读
- MySQL 读写分离
- 印度星龟饲养常见问题分析
- 数据库MYSQL的查询
- 重学SpringMVC:框架原理解读 + 简单入门程序+组件分析.
- ijkPlayer源码分析 PacketQueue分析
- MySQL 8.0新特性之隐藏字段的深入讲解
- 性能工具之 C/C++ 分析工具 valgrind
- 想MYSQL数据库运维高效,这些开发规范总结,参考着用
- ubuntu18.04中Mysql5.7数据库安装及远程登录
- MySQL不同版本多实例部署