报错信息:
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)
设置事务传播行为,有事务时,就加入该事务执行,无事务时,就在无事务状态下执行
我刚做的小程序哦,欢迎交流程序问题哦~