org.springframework.dao.CannotAcquireLockException 的解决》

直接上 bug 的详细信息

2012-03-12 15:20:31 XmlBeanDefinitionReader [INFO] Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
2012-03-12 15:20:31 SQLErrorCodesFactory [INFO] SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
2012-03-12 15:20:31 ExceptionUtil [ERROR] SqlMapClient operation; SQL [];
--- The error occurred in com/defonds/syncpath/dao/operation.xml.
--- The error occurred while applying a parameter map.
--- Check the operation.updateShareStatus-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/defonds/syncpath/dao/operation.xml.
--- The error occurred while applying a parameter map.
--- Check the operation.updateShareStatus-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
org.springframework.dao.CannotAcquireLockException: SqlMapClient operation; SQL [];
--- The error occurred in com/defonds/syncpath/dao/operation.xml.
--- The error occurred while applying a parameter map.
--- Check the operation.updateShareStatus-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/defonds/syncpath/dao/operation.xml.
--- The error occurred while applying a parameter map.
--- Check the operation.updateShareStatus-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transactionat org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:244)at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:212)at com.defonds.frameworkcommons.dao.BaseDaoImpl.execute(BaseDaoImpl.java:31)at com.defonds.frameworkcommons.dao.BaseDaoImpl.update(BaseDaoImpl.java:97)at com.defonds.syncpath.service.operation.impl.OperationServiceImpl.revokeSharedFolder(OperationServiceImpl.java:287)at com.defonds.syncpath.service.share.impl.ShareServiceImpl.handleRevokeSharedFolder(ShareServiceImpl.java:312)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at com.defonds.interfaceframework.controller.Action.invokeMethod(Action.java:256)at com.defonds.interfaceframework.controller.Action.execute(Action.java:206)at com.defonds.interfaceframework.controller.DispatcherServlet.service(DispatcherServlet.java:144)at com.defonds.syncpath.common.ArcSyncDispatcherServlet.service(ArcSyncDispatcherServlet.java:51)at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)at java.lang.Thread.run(Thread.java:619)

分析原因

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

 private OperationService operationService;

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

解决方案

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

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

原文地址:http://www.xuebuyuan.com/958812.html

转载于:https://www.cnblogs.com/davidwang456/p/4270458.html

java.sql.SQLException: Lock wait timeout exceeded --转相关推荐

  1. java.sql.SQLException: Lock wait timeout exceeded

    2019独角兽企业重金招聘Python工程师标准>>> 先说我我的解决方法:找到锁住的线程然后kill掉. mysql> kill thr_id; 下面简单分析一下到底应该ki ...

  2. java lock wait_java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction

    在开发测试过程中发现出了这个问题: RECHARGE:业务,数据: {"platformUserNo":"RPD_1512632756191","am ...

  3. Caused by: java.sql.SQLException: GC overhead limit exceeded处理百万数据出现的异常

    Caused by: java.sql.SQLException: GC overhead limit exceeded处理百万数据出现的异常 参考文章: (1)Caused by: java.sql ...

  4. mysql 中lock wait_应用中MYSQL 报错Lock wait timeout exceeded; try restarting transaction

    最近开发的应用开始做性能测试.在小于80用户并发的时候一切OK,并发量到100用户时,持续压5分钟.应用开始报错,并且只有1次错误,持续时间长,比如10分钟,会报3次. 日志如下: Caused by ...

  5. Lock wait timeout exceeded; try restarting......

    2019独角兽企业重金招聘Python工程师标准>>> mysql异常java.sql.SQLException: Lock wait timeout exceeded; try r ...

  6. mysql死锁释放时间参数_【Mysql】mysql 事务未提交导致死锁 Lock wait timeout exceeded; try restarting transaction 解决办法...

    问题场景 问题出现环境: 1.在同一事务内先后对同一条数据进行插入和更新操作: 2.多台服务器操作同一数据库: 3.瞬时出现高并发现象: 不断的有一下异常抛出,异常信息: org.springfram ...

  7. mysql 告警 异常 处理_mysql异常解决方案 - Lock wait timeout exceeded异常

    问题 最近线上业务在运行过程中,遇到如下异常: 2021-01-13 10:25:20.838 WARN [http-nio-7010-exec-104][SqlExceptionHelper.jav ...

  8. mysql当执行delete语句时备份_mysql中,执行delete语句时出现Lock wait timeout exceeded问题...

    问题描述: 当我插入一条记录时,在调用save方法的时候出现了异常(记录重复了),导致了后面的commit语句不能执行了.这时我在数据库中删除重复记录时发现该表已经被锁上了.即出现 错误.但过了一会再 ...

  9. SQL性能优化常见措施(Lock wait timeout exceeded)

    SQL性能优化常见措施 目 录 1.mysql中explain命令使用 2.mysql中mysqldumpslow的使用 3.mysql中修改my.ini配置文件记录日志 4.mysql中如何加索引 ...

最新文章

  1. Google跨平台UI框架 Flutter beta 重磅发布,这里有你需要了解的一切
  2. 说出一些数据库优化方面的经验?
  3. How do annotations work internally--转
  4. python输出日期语句_python输出语句怎么用
  5. Main execution in Scala - Scala应用的入口
  6. Oracle 学习----:查看当前时间与Sqlserver语句不一样了
  7. 由内省引出JavaBean的讲解
  8. OpenGL ES SDK for Android - 4
  9. 机器学习概念 —— 样本距离矩阵
  10. linux配置路径,Linux下配置搜索路径
  11. NPOI2.0学习(三)
  12. python3.7.2安装pywifi_Python pywifi包_程序模块 - PyPI - Python中文网
  13. 2013北理机试-中缀转前缀
  14. 联想换机助手_三星s换机助手下载-三星S换机助手 安卓版v3.6.07.11-pc6手机下载
  15. excel数据透视表之交叉表分组
  16. Latex的一些排版技巧
  17. 5g理论速度_5G手机用4G套餐速度达300M每秒,其原因令人费解,西瓜视频聊科技...
  18. sql中大于等于小于的写法
  19. 查看Chrome浏览器版本及下载对应的webdriver,并下载安装
  20. FL Studio教程之Fruity Blood Overdrive插件

热门文章

  1. sis防屏蔽程序_弱电工程屏蔽机房设计方案
  2. cumsum在matlab中,matlab中cumsum函数和sum函数详解
  3. 2019河北高职计算机专科学校录取分数线,2019河北高考专科院校录取分数线_专科各院校投档线_一品高考网...
  4. 登录界面的滑动_【提醒】电子税务局登录方式有变化! 8月31日关闭“原方式登录”...
  5. 配置oracle 11g环境,oracle 11g 的安装环境的配置
  6. 互斥信号量的原理与创建
  7. tem在c语言中的作用,Temtem状态有什么效果 Temtem各状态效果介绍_游侠网
  8. Android:Activity(页面)的生存周期
  9. 模拟银行取钱 (多线程操作的好处)
  10. tensorflow2.0 与tensorflow1.0的性能区别