博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
数据库死锁Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
阅读量:5807 次
发布时间:2019-06-18

本文共 8117 字,大约阅读时间需要 27 分钟。

  hot3.png

异常内容:

com.wlyd.fmcgwms.persistence.beans.platform.job.CycleFetchInterfaceInfoTaskJob] failed; nested exception is org.springframework.dao.CannotAcquireLockException: ### Error updating database.  Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction### The error may involve defaultParameterMap### The error occurred while setting parameters### SQL: update cd_customer_P0000001      SET CDST_CUSTOMER_NAME = ?,                       CDST_CONTACT = ?,                       CDST_CONTACTOR_TELL = ?,                       CDST_ADDRESS = ?,                                     CDST_CUSTOMER_CODE = ?,                       CDST_CUSTOMER_STATUS = ?,                       INTERFACE_UPDATETIME= ?,                       INTERFACE_SERIALNO= ?,                        CDST_SOURCE = ?      where CDST_ID = ?### Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction; SQL []; Lock wait timeout exceeded; try restarting transaction; nested exception is java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction	at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:320)	at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113)	at org.quartz.core.JobRunShell.run(JobRunShell.java:216)	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)Caused by: org.springframework.dao.CannotAcquireLockException: ### Error updating database.  Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction### The error may involve defaultParameterMap### The error occurred while setting parameters### SQL: update cd_customer_P0000001      SET CDST_CUSTOMER_NAME = ?,                       CDST_CONTACT = ?,                       CDST_CONTACTOR_TELL = ?,                       CDST_ADDRESS = ?,                                     CDST_CUSTOMER_CODE = ?,                       CDST_CUSTOMER_STATUS = ?,                       INTERFACE_UPDATETIME= ?,                       INTERFACE_SERIALNO= ?,                        CDST_SOURCE = ?      where CDST_ID = ?### Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction; SQL []; Lock wait timeout exceeded; try restarting transaction; nested exception is java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:265)	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:368)	at com.sun.proxy.$Proxy176.update(Unknown Source)	at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:254)	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82)	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)	at com.sun.proxy.$Proxy183.updateTable(Unknown Source)	at com.wlyd.fmcgwms.service.platform.impl.APIForWaasServiceImpl.insertOrUpdateProduct(APIForWaasServiceImpl.java:674)	at com.wlyd.fmcgwms.service.platform.impl.APIForWaasServiceImpl.insertOrUpdateProduct(APIForWaasServiceImpl.java:561)	at sun.reflect.GeneratedMethodAccessor322.invoke(Unknown Source)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:606)	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)	at com.sun.proxy.$Proxy210.insertOrUpdateProduct(Unknown Source)	at com.wlyd.fmcgwms.persistence.beans.platform.job.CycleFetchInterfaceInfoTaskJob.fetch(CycleFetchInterfaceInfoTaskJob.java:95)	at sun.reflect.GeneratedMethodAccessor316.invoke(Unknown Source)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:606)	at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)	at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:311)	... 3 moreCaused by: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3562)	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3494)	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1960)	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2114)	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2696)	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2105)	at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1367)	at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493)	at sun.reflect.GeneratedMethodAccessor60.invoke(Unknown Source)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:606)	at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:58)	at com.sun.proxy.$Proxy160.execute(Unknown Source)	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)	at sun.reflect.GeneratedMethodAccessor151.invoke(Unknown Source)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:606)	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59)	at com.sun.proxy.$Proxy322.update(Unknown Source)	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)	at sun.reflect.GeneratedMethodAccessor148.invoke(Unknown Source)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:606)	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)	... 30 more

此处错误是一个Update语句造成的死锁情况,需要分析此update方法操作被事务的代码是否被事务包裹过长或事务方法嵌套。

** 分析原因:**

com.wlyd.fmcgwms.persistence.beans.platform.job.CycleFetchInterfaceInfoTaskJob] failed; nested exception is org.springframework.dao.CannotAcquireLockException:

Spring 事务嵌套造成死锁。

解决方案:

当前调用事务的方法设置为 Propagation.SUPPORTS:

@Transactional(propagation=Propagation.SUPPORTS)//by Defonds,for BUG094537@Overridepublic void updateCustomer(Model model);

转载于:https://my.oschina.net/boonya/blog/836094

你可能感兴趣的文章
IIS7内建账号,应用程序池
查看>>
之字形打印矩阵
查看>>
我的2014-相对奢侈的生活
查看>>
zoj 2412 dfs 求连通分量的个数
查看>>
NLP自然语言处理学习笔记一(环境准备)
查看>>
李开复:中国第四波创业浪潮来临
查看>>
数组中连续重复数据删选且记下所在索引-demo
查看>>
管道和多路复用器
查看>>
第六周作业 百词斩对比可可英语
查看>>
李天平老师回复:如何稳步提高自己的技术?
查看>>
SQL Server 计算汉字笔画函数
查看>>
【算法】LeetCode算法题-Merge Two Sorted List
查看>>
子查询注意这几点, 就可以写出好的sql语句
查看>>
在项目中用run as java aplication调试类
查看>>
python-建造者模式
查看>>
常用模块
查看>>
RadioButtonList中的默认项(Selected)不触发OnSelectedIndexChanged
查看>>
Javascript选择checkbox
查看>>
jQuery系列:Ajax
查看>>
Ruiy自我识人做事领悟录ing
查看>>