update 时发生死锁

8 篇文章 0 订阅

报错信息:

org.springframework.dao.CannotAcquireLockException: 
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
### The error may involve com.ifrabbit.nk.express.domain.TableInfo._updateIgnoreNull-Inline
### The error occurred while setting parameters
### SQL: update tapp_tableinfo SET tableinfo_content=?,tableinfo_floatparama=?,tableinfo_floatparamb=?,tableinfo_floatparamc=?,tableinfo_floatparamd=?,tableinfo_floatparame=? where  tableinfo_id=?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
; SQL []; Lock wait timeout exceeded; try restarting transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:259)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
    at com.sun.proxy.$Proxy97.update(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:294)
    at org.springframework.data.mybatis.repository.support.SqlSessionRepositorySupport.update(SqlSessionRepositorySupport.java:109)
    at org.springframework.data.mybatis.repository.support.SimpleMybatisRepository.updateIgnoreNull(SimpleMybatisRepository.java:106)
    at sun.reflect.GeneratedMethodAccessor295.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$Query

死锁原因:

有多个进程在操作同一张表,导致了死锁,等待超时

解决问题:

在改方法上加上注释    @Transactional(propagation= Propagation.SUPPORTS)

设置事务传播行为,有事务时,就加入该事务执行,无事务时,就在无事务状态下执行

 

 

 

 

我刚做的小程序哦,欢迎交流程序问题哦~ 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值