Java. SQL. sqlexception: Lock wait timeout exceeded | solution to cannotacquirelockexception

Source: Internet
Author: User
Java. SQL. sqlexception: Lock wait timeout exceeded | org. springframework. Dao. cannotacquirelockexception solution in spring Development notes

Go directlyBug details:

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 transactionorg.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)

Cause Analysis:

Nested spring transactions cause deadlocks. Operationservice is embedded in fileserviceimpl:

private OperationService operationService;

In the delete method of fileserviceimpl, operations are performed on MySQL file tables, while the revokesharedfolder method in operationservice also performs update operations on the same table. Transaction nesting causes deadlocks.

Solution:

The method for calling the transaction is set to propagation. supports:

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.