-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Lock wait timeout exceeded; try restarting transaction
PostPosted: Fri Dec 09, 2011 10:17 am 
Newbie

Joined: Tue Nov 16, 2010 9:43 am
Posts: 19
I am using MYSQL 5.1 In my application, in single trasaction am inserting a new record and updating a other records and iam getting the following the exception .


java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:57)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2329)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2836)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:677)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:669)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:665)
at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:740)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:737)
at com.dtdc.ng.dao.purchase.GoodsIssueDAOImpl.updateGoodsIssueToFranchiseeDetails(GoodsIssueDAOImpl.java:1059)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy27.updateGoodsIssueToFranchiseeDetails(Unknown Source)
at com.dtdc.ng.bs.purchase.goods.GoodsIssueServiceImpl.saveGoodsIssueFrachiseeDetails(GoodsIssueServiceImpl.java:1232)
at com.dtdc.ng.action.purchase.goods.GoodsIssueFranchiseeAction.approveGoodsIssueFranchiseeDetails(GoodsIssueFranchiseeAction.java:527)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at com.capgemini.lbs.framework.wrappers.CTBSRequestProcessor.processActionPerform(CTBSRequestProcessor.java:30)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.capgemini.lbs.framework.filters.CTBSFilter.doFilter(CTBSFilter.java:101)
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:127)
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:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
2011-12-09 19:35:37,694 [http-8080-1] WARN - SQL Error: 1205, SQLState: 41000
2011-12-09 19:35:37,694 [http-8080-1] ERROR - Lock wait timeout exceeded; try restarting transaction
2011-12-09 19:35:37,725 [http-8080-1] DEBUG - Looking up default SQLErrorCodes for DataSource [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 5, acquireRetryAttempts -> 3, acquireRetryDelay -> 3, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 3, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 2u6hgf8k9pvg7r14x3lqn|c11e94, debugUnreturnedConnectionStackTraces -> true, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 2u6hgf8k9pvg7r14x3lqn|c11e94, idleConnectionTestPeriod -> 500, initialPoolSize -> 10, jdbcUrl -> jdbc:mysql://10.58.194.142:3306/dtdc_ctbs_plus, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 600, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 100, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 5, numHelperThreads -> 5, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> select 1, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, statementDestroyerNumActiveThreads -> -1, statementDestroyerNumConnectionsInUseAllUsers -> -1, statementDestroyerNumConnectionsInUseDefaultUser -> -1, statementDestroyerNumConnectionsWithDeferredDestroyStatementsAllUsers -> -1, statementDestroyerNumConnectionsWithDeferredDestroyStatementsDefaultUser -> -1, statementDestroyerNumDeferredDestroyStatementsAllUsers -> -1, statementDestroyerNumDeferredDestroyStatementsDefaultUser -> -1, statementDestroyerNumIdleThreads -> -1, statementDestroyerNumTasksPending -> -1, statementDestroyerNumThreads -> -1, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 400, usesTraditionalReflectiveProxies -> false ]]
2011-12-09 19:35:37,725 [http-8080-1] DEBUG - Fetching JDBC Connection from DataSource
2011-12-09 19:35:37,725 [http-8080-1] DEBUG - Returning JDBC Connection to DataSource
2011-12-09 19:35:37,725 [http-8080-1] DEBUG - Database product name cached for DataSource [com.mchange.v2.c3p0.ComboPooledDataSource@8ec946c7]: name is 'MySQL'
2011-12-09 19:35:37,725 [http-8080-1] DEBUG - SQL error codes for 'MySQL' found
2011-12-09 19:35:37,725 [http-8080-1] DEBUG - Translating SQLException with SQL state '41000', error code '1205', message [Lock wait timeout exceeded; try restarting transaction]; SQL was [insert into dtdc_f_goods_issue_approval_detl (TRANSACTION_DATE, APPROVAL_LEVEL, APPROVAL_STATUS, USER_ID, GOODS_ISSUE_ID) values (?, ?, ?, ?, ?)] for task [Hibernate operation: could not insert: [com.dtdc.domain.purchase.GoodsIssueApprovalDtlsDO]]
2011-12-09 19:35:37,725 [http-8080-1] DEBUG - Closing Hibernate Session
2011-12-09 19:35:37,725 [http-8080-1] DEBUG - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2011-12-09 19:35:37,725 [http-8080-1] DEBUG - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
2011-12-09 19:35:37,725 [http-8080-1] DEBUG - rollback
2011-12-09 19:35:37,756 [http-8080-1] DEBUG - re-enabling autocommit
2011-12-09 19:35:37,756 [http-8080-1] DEBUG - rolled back JDBC Connection
2011-12-09 19:35:37,756 [http-8080-1] DEBUG - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!


Top
 Profile  
 
 Post subject: Re: Lock wait timeout exceeded; try restarting transaction
PostPosted: Sat Dec 10, 2011 2:36 am 
Beginner
Beginner

Joined: Wed Jan 07, 2009 7:07 pm
Posts: 26
What kind of Hibernate locking are you using ? Also check your DB isolation level.

Thanks
-Vishal


Top
 Profile  
 
 Post subject: Lock wait timeout exceeded; try restarting transaction
PostPosted: Mon Dec 12, 2011 1:45 am 
Newbie

Joined: Tue Nov 16, 2010 9:43 am
Posts: 19
Hi
iam not using any kind of locking mechanisms,
and the DB isolation level is REPEATABLE-READ.


Top
 Profile  
 
 Post subject: Re: Lock wait timeout exceeded; try restarting transaction
PostPosted: Mon Dec 12, 2011 1:46 am 
Newbie

Joined: Tue Nov 16, 2010 9:43 am
Posts: 19
Example code is

session = hibernateTemplate.getSessionFactory().getCurrentSession();

tx = session.beginTransaction();
...
;;;
tx.commit;

if exception roll back the transaction and re throwing the exception


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.