ERROR sn(ls8-resource-server) hn(mdw) c.i.i.i.t.c.BeforeWfFeeController:61 - 发送失败
org.springframework.dao.DeadlockLoserDataAccessException: 
### Error updating database.  Cause: 
com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Deadlock found when trying 
to get lock; try restarting transaction
### The error may exist in com/**/FeeXXMapper.java (best guess)
### The error may involve com.**.mapper.FeeXXMapper.batchInsert-Inline
### The error occurred while setting parameters
### SQL: insert into 
fee_xx_item(id,apply_id,apply_detail_id,parent_apply_id,parent_apply_detail_id,parent_apply
_detail_item_id,fee_code,fee_calibre,consumption_object,apply_amount,approval_amount,ext_in
fo,complete_flag,fee_control_id,seq,enable_this_product,this_product_illustrate,product_cod
e,frozen_amount,enable_frozen) values   (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
### Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Deadlock found
 when trying to get lock; try restarting transaction
; Deadlock found when trying to get lock; try restarting transaction; nested exception is
 com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Deadlock found when trying
 to get lock; try restarting transaction

最近在做压测时遇到MySQLTransactionRollbackException: Deadlock...的问题,经排查发生的原因是:在接口中使用Transactional注解,且该接口的业务逻辑夹杂在两个或多个mapper(泛指对数据库的增删改)方法中间,业务逻辑处理时间长,高并发的状态下则会导致TransactionRollbackException,所以需要将与数据库操作的增删改方法都统一放在接口的最后。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐