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

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

时间: 2024-10-05 23:54:33

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

mysql Lock wait timeout exceeded

MySQL 事务没有提交导致 锁等待 Lock wait timeout exceeded java.lang.Exception:### Error updating database.  Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction### The error may involve defaultParameterMap### The error occurred wh

ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

问题描述: 研发突然找我,遇到了mysql的 ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction,具体报错如下: org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158) Caused by: java.io .IOException: java.sql.SQLException: Lock wait timeout exceeded;

ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction解决

一.问题描述: 同事反馈线上一个表有其中一条数据无法删除,其他都正常,我拿到删数据的sql,尝试执行,报错如下: mysql> delete from facebook_posts where id = 7048962; ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction 二.问题处理 从报错信息看,应该是关于这条数据有事物未提交,锁等待超时了,下面我们就开始验证并解决问题 1.在sql执行期间,通

mysql死锁,等待资源,事务锁,Lock wait timeout exceeded; try restarting transaction解决

前面已经了解了InnoDB关于在出现锁等待的时候,会根据参数innodb_lock_wait_timeout的配置,判断是否需要进行timeout的操作,本文档介绍在出现锁等待时候的查看及分析处理: 在InnoDB Plugin之前,一般通过show full processlist(很难发现被锁的行记录问题所在)和show engine innodb status命令查看当前的数据库请求,然后再判断当前事务中锁的情况.随着mysql的发展,已经提供更加便捷的方法来监控数据库中的锁等待现象了.

Lock wait timeout exceeded数据库死锁问题

环境 MySQL5.5 现象 A.数据更新或新增后数据经常自动回滚. B.表操作总报 Lock wait timeout exceeded 并长时间无反应 解决方法 A.应急方法:show processlist; kill掉出现问题的进程 B.根治方法:select * from innodb_trx 查看有是哪些事务占据了表资源. C.我的方法:设置MySQL锁等待超时 innodb_lock_wait_timeout=50 ,autocommit=on 该类问题导致原因 据我分析,Mysq

mysql Lock wait timeout exceeded; try restarting transaction解决

前面已经了解了InnoDB关于在出现锁等待的时候,会根据参数innodb_lock_wait_timeout的配置,判断是否需要进行timeout的操作,本文档介绍在出现锁等待时候的查看及分析处理: 在InnoDB Plugin之前,一般通过show full processlist(很难发现被锁的行记录问题所在)和show engine innodb status命令查看当前的数据库请求,然后再判断当前事务中锁的情况.随着mysql的发展,已经提供更加便捷的方法来监控数据库中的锁等待现象了.

ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction解决办法

一.问题描述: 同事反馈线上一个表有其中一条数据无法删除,其他都正常,我拿到删数据的sql,尝试执行,报错如下: mysql> delete from facebook_posts where id = 7048962; ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction 二.问题处理 从报错信息看,应该是关于这条数据有事物未提交,锁等待超时了,下面我们就开始验证并解决问题 1.在sql执行期间,通

SQL state [72000]; error code [1013]; ORA-03111: 通信通道收到中断; java.sql.SQLException: ORA-01745: 无效的主机/绑定变量名;java.sql.SQLException: ORA-01013: 用户请求取消当前的操作

1.oracle批量插入 2.java.sql.SQLException: ORA-01745: 无效的主机/绑定变量名(数据太多的时候出现解决方法限制条数插入) /** * 按指定大小,分隔集合,将集合按规定个数分为n个部分 * @param <T> * * @param list * @param len * @return */ public static <T> List<List<T>> splitList(List<T> list,

【MySQL】关于MySQL出现lock wait timeout exceeded 的解决方案

关于MySQL出现lock wait timeout exceeded; try restarting transaction 的解决方案. 一.问题抛出 在做查询语句时,MySQL 抛出了这样的异常: MySQL server error report:Array ( [0] => Array ( [message] => MySQL Query Error ) [1] => Array ( [sql] => SELECT * FROM taobao_trade WHERE or