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 transaction
at 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
@Override
public void delete(int uid, int[] itemIds) {
if (itemIds != null && itemIds.length > 0) {

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

java.sql.SQLException: Lock wait timeout exceeded --转的更多相关文章

  1. Spring_错误 java.sql.SQLException: Lock wait timeout exceeded | CannotAcquireLockException 的解决

    java.sql.SQLException: Lock wait timeout exceeded |  org.springframework.dao.CannotAcquireLockExcept ...

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

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

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

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

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

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

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

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

  6. 项目中遇到的死锁问题: 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. Caused by: java.sql.BatchUpdateException: Transaction error, need to rollback. errno:1205 Lock wait timeout exceeded; try restarting transaction

    更新的时候报 Caused by: java.sql.BatchUpdateException: Transaction error, need to rollback. errno:1205 Loc ...

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

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

随机推荐

  1. ArcGIS Engine生成等值线(C#)

    原文:ArcGIS Engine生成等值线(C#) 本文介绍c#写的利用ArcGIS Engine生成等值线的方法.c#写的根据雨量站的降雨量值内插出降雨量等值线的功能.做几点说明:根据离散点生成等值 ...

  2. 带你走进EJB--MDB实现发送邮件(3)

    接上篇,在业务逻辑中已经发送JMS消息,而接下来的消息驱动Bean作为JMS消息监听器,主要是负责监听指定的JMS消息,此时已经接受到JMS的消息,那么MDB的onMessage()方法会被触发.调用 ...

  3. div+css实现导航示意箭头

    1.Div的宽高为100 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <h ...

  4. uml类图的几种关系

    UML类图几种关系的总结   在UML类图中,常见的有以下几种关系: 泛化(Generalization),  实现(Realization),关联(Association),聚合(Aggregati ...

  5. VM8下安装Mac OS X 10.7

    下载Mac OS X  10.7 安装包http://115.com/file/clj1iu8m#            下载HJMac http://115.com/file/cljyu1rh#   ...

  6. 【 随笔 】 JavaScript 图形库的流行度调查

    2014年可以说是 JavaScript 最风光的一年,成为上升最快的语言,在 Github 上最受关注的前10个仓库中,有7个是基于 JavaScript 开发的,数不胜数的函数库可适应于各种需求. ...

  7. ES6/ES2015核心内容

    ECMAScript定义了: JS语言语法 – 语法解析规则.关键字.语句.声明.运算符等. 类型 – 布尔型.数字.字符串.对象等. 原型和继承 内建对象和函数的标准库 – JSON.Math.数组 ...

  8. MySQL问题集绵

    1.MYSQL can't create table(errno:150) 详细:[Err] 1005 - Can't create table '.\ejforum\ejf_attach.frm' ...

  9. ADO.NET——获取output 和 return值

    程序代码 //存储过程 //Create PROCEDURE MYSQL // @a int, // @b int //AS // return @a + @b //GO SqlConnection ...

  10. 社区商业试玩O2O:良渚文化村新街坊牵手阿里巴巴

    在电商时代,越来越多的人选择便捷的网上购物,使得实体商业受到了不小的冲击,各种大型的购物中心.购物广场已经不再那么人气十足,因此一些特色商业街区.社区商业频频出现,也不乏一些新玩儿法. 阿里巴巴(专题 ...