java.sql.SQLException: Lock wait timeout exceeded |  org.springframework.dao.CannotAcquireLockException 的解决

直接上 bug 的详细信息

  1. 2012-03-12 15:20:31 XmlBeanDefinitionReader [INFO] Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
  2. 2012-03-12 15:20:31 SQLErrorCodesFactory [INFO] SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
  3. 2012-03-12 15:20:31 ExceptionUtil [ERROR] SqlMapClient operation; SQL [];
  4. --- The error occurred in com/defonds/syncpath/dao/operation.xml.
  5. --- The error occurred while applying a parameter map.
  6. --- Check the operation.updateShareStatus-InlineParameterMap.
  7. --- Check the statement (update failed).
  8. --- Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
  9. --- The error occurred in com/defonds/syncpath/dao/operation.xml.
  10. --- The error occurred while applying a parameter map.
  11. --- Check the operation.updateShareStatus-InlineParameterMap.
  12. --- Check the statement (update failed).
  13. --- Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
  14. org.springframework.dao.CannotAcquireLockException: SqlMapClient operation; SQL [];
  15. --- The error occurred in com/defonds/syncpath/dao/operation.xml.
  16. --- The error occurred while applying a parameter map.
  17. --- Check the operation.updateShareStatus-InlineParameterMap.
  18. --- Check the statement (update failed).
  19. --- Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
  20. --- The error occurred in com/defonds/syncpath/dao/operation.xml.
  21. --- The error occurred while applying a parameter map.
  22. --- Check the operation.updateShareStatus-InlineParameterMap.
  23. --- Check the statement (update failed).
  24. --- Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
  25. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:244)
  26. at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
  27. at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:212)
  28. at com.defonds.frameworkcommons.dao.BaseDaoImpl.execute(BaseDaoImpl.java:31)
  29. at com.defonds.frameworkcommons.dao.BaseDaoImpl.update(BaseDaoImpl.java:97)
  30. at com.defonds.syncpath.service.operation.impl.OperationServiceImpl.revokeSharedFolder(OperationServiceImpl.java:287)
  31. at com.defonds.syncpath.service.share.impl.ShareServiceImpl.handleRevokeSharedFolder(ShareServiceImpl.java:312)
  32. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  33. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  34. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  35. at java.lang.reflect.Method.invoke(Method.java:597)
  36. at com.defonds.interfaceframework.controller.Action.invokeMethod(Action.java:256)
  37. at com.defonds.interfaceframework.controller.Action.execute(Action.java:206)
  38. at com.defonds.interfaceframework.controller.DispatcherServlet.service(DispatcherServlet.java:144)
  39. at com.defonds.syncpath.common.ArcSyncDispatcherServlet.service(ArcSyncDispatcherServlet.java:51)
  40. at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  41. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  42. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  43. at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
  44. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
  45. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  46. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  47. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  48. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  49. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
  50. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  51. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  52. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
  53. at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
  54. at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
  55. at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
  56. at java.lang.Thread.run(Thread.java:619)

分析原因

Spring 事务嵌套造成死锁。FileServiceImpl 里嵌入了 OperationService:

  1. private OperationService operationService;

FileServiceImpl 的 delete 方法里对 MySQL 的 file 表有操作,而 OperationService 里的 revokeSharedFolder 方法也对同一张表有更新操作。事务嵌套,造成死锁。

解决方案

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

    1. @Transactional(propagation=Propagation.SUPPORTS)//by Defonds,for BUG094537
    2. @Override
    3. public void delete(int uid, int[] itemIds) {
    4. if (itemIds != null && itemIds.length > 0) {

Spring_错误 java.sql.SQLException: Lock wait timeout exceeded | CannotAcquireLockException 的解决的更多相关文章

  1. java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction

    java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction问题 1.问题描述 执行了几条update语句 ...

  2. MySQL应用报错:java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction

    开发反馈,某业务系统插入一条记录的时候,日志报错,插入失败: ### Error updating database. Cause: java.sql.SQLException: Lock wait ...

  3. java.sql.SQLException: Lock wait timeout exceeded --转

    org.springframework.dao.CannotAcquireLockException 的解决> 直接上 bug 的详细信息: 2012-03-12 15:20:31 XmlBea ...

  4. MySql系列:中文写入数据库出现错误java.sql.SQLException: Incorrect string value: '\xE5\xxxx' for column 'xxxx' at row 1及其解决方法

    在将kft-activiti-demo的数据库连接改为mysql之后,可以正常登陆,但是在新建请假流程的时候出现如下错误:   Caused by: java.sql.SQLException: In ...

  5. 出现java.sql.SQLException: No suitable driver的几种解决办法

    今天在用C3p0连接MySql数据库 这个时候出现了上面的错误, 一般来说这种错误有3个方向解决 一般都是db的配置的问题 ,一定要小心DB 的配置 八月 19, 2017 8:30:46 下午 co ...

  6. Mysql错误:ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

    昨晚添加完索引之后, 查询整表的时候抛出Lock wait timeout exceeded; try restarting transaction, 吓死小白的我, 为什么条件查询可以, 整表查不了 ...

  7. Mysql错误: ERROR 1205: Lock wait timeout exceeded解决办法(MySQL锁表、事物锁表的处理方法)

    Java执行一个SQL查询未提交,遇到1205错误. java.lang.Exception: ### Error updating database.  Cause: java.sql.SQLExc ...

  8. MySQL_事务没有提交导致 锁等待 Lock wait timeout exceeded

    java.lang.Exception:### Error updating database.  Cause: java.sql.SQLException: Lock wait timeout ex ...

  9. MySQL 事务没有提交导致 锁等待 Lock wait timeout exceeded

    java.lang.Exception: ### Error updating database.  Cause: java.sql.SQLException: Lock wait timeout e ...

随机推荐

  1. Docker 入门 第一部分: 定位和设置

    目录 Docker 入门 第一部分: 定位和设置 Docker概念 镜像和容器 容器和虚拟机 准备你的Docker环境 测试 Docker 的版本 测试 Docker 安装 回顾 总结 Docker ...

  2. JMS学习(五)--ActiveMQ中的消息的持久化和非持久化 以及 持久订阅者 和 非持久订阅者之间的区别与联系

    一,消息的持久化和非持久化 ①DeliveryMode 这是传输模式.ActiveMQ支持两种传输模式:持久传输和非持久传输(persistent and non-persistent deliver ...

  3. mysql 创建用户自定义函数

    为了防止分号产生的中途输出,自己定义一个 分隔符,这里仿照mysql官方的例子:使用两个美元符号 $$ 作为分割符号,下面这段代码就是创建一个自定义mysql函数的原型了,可以在这个基础上修改,这样, ...

  4. argunlar 1.0.0 【hello,world】

    <!DOCTYPE html><html lang="en" ng-app><head>    <meta charset="U ...

  5. python技巧 使用值来排序一个字典

    In [8]: a={'x':11,'y':22,'c':4} In [9]: import operator In [10]: sorted(a.items(),key=operator.itemg ...

  6. python 的print和特殊方法 __str__和__repr__

    先提出一个疑问,为什么print函数可以直接打印参数呢?即使是数字?例如print 1,就会打印1.我们知道1的类型是整型(题外话,在python中1是常量,也是类int的对象,而java中1只是常量 ...

  7. 各浏览器 position: fixed 造成的bug 通用解决办法,Safari, iOS

    将原来使用 position: fixed  的元素外层包裹一个 div.fixedWrapper .fixedWrapper { width: 100%; overflow: hidden; pos ...

  8. spring的事务控制

    1.事务介绍 (1)特性:ACID Atomicity(原子性):事务中的所有操作要么全做要么全不做 Consistency(一致性):事务执行的结果使得数据库从一个一致性状态转移到另一个一致性状态 ...

  9. Linux下内存泄漏工具【转】

    转自:http://www.cnblogs.com/guochaoxxl/p/6970090.html 概述 内存泄漏(memory leak)指由于疏忽或错误造成程序未能释放已经不再使用的内存的情况 ...

  10. 洛谷P1886 滑动窗口

    传送门啦 以最大值为例,既然我们想要保证队列开头为答案,那么我们就要保证每次更新使最大值一直放在队列.那么如果存储的最大值该弹出了怎么办呢?我们只需要记录下每个元素的位置,判断是否在区间内即可. 队头 ...