1. timemachine
  2. scheduler
Issue #23 resolved

MySQL: Deadlock found when trying to get lock

Zemian Deng
created an issue

When adding many schedules, and if some are to repeat only once (delete happens), we get this error.

18:34:05 TimeMachineScheduler-JobTask-Thread-1 INFO timemachine.scheduler.jobtask.LoggerJobTask| Running: Scheduler nodeId=1, schedulerId=1, jobId=34, scheduleId=52, scheduleName=job1-schedule2, scheduledRun=07/15/2012 18:34:05, nextRun=07/15/2012 18:35:05 18:34:05 TimeMachineScheduler-System-Thread-1 WARN org.hibernate.engine.jdbc.spi.SqlExceptionHelper| SQL Error: 1213, SQLState: 40001 18:34:05 TimeMachineScheduler-System-Thread-1 ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper| Deadlock found when trying to get lock; try restarting transaction 18:34:05 TimeMachineScheduler-System-Thread-1 ERROR timemachine.scheduler.service.PollingScheduleRunner| Failed to poll dataStore for schedule to run. org.hibernate.exception.LockAcquisitionException: Deadlock found when trying to get lock; try restarting transaction at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:94) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110) at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129) at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81) at $Proxy18.executeUpdate(Unknown Source) at org.hibernate.hql.internal.ast.exec.MultiTableDeleteExecutor.execute(MultiTableDeleteExecutor.java:138) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:413) at org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:282) at org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1268) at org.hibernate.internal.QueryImpl.executeUpdate(QueryImpl.java:116) at timemachine.scheduler.hibernate.HibernateDataStore$19.onSession(HibernateDataStore.java:799) at timemachine.scheduler.hibernate.HbmSessionTemplate.withSession(HbmSessionTemplate.java:67) at timemachine.scheduler.hibernate.HibernateDataStore.deleteDeadSchedules(HibernateDataStore.java:788) at timemachine.scheduler.service.PollingScheduleRunner.run(PollingScheduleRunner.java:355) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1064) 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 sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) ... 14 more

Comments (3)

  1. Log in to comment