Hi,
We are getting deadlocks when job instances/executions/steps are being created. This occurs when multiple jobs are schedule and started at the same time. We have jobs which runs for every 2 minutes. This causes each transaction to take longer, providing more opportunity for deadlock. Is anyone encountered this issue? What might be the issue?

This is one of the the exceptions we have got
org.springframework.dao.DeadlockLoserDataAccessExc eption: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; Deadlock found when trying to get lock; try restarting transaction; nested exception is com.mysql.jdbc.exceptions.MySQLTransactionRollback Exception: Deadlock found when trying to get lock; try restarting transaction
at org.springframework.jdbc.support.SQLErrorCodeSQLEx ceptionTranslator.translate(SQLErrorCodeSQLExcepti onTranslator.java:300)
at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:606)
at org.springframework.jdbc.core.JdbcTemplate.update( JdbcTemplate.java:791)
at org.springframework.jdbc.core.JdbcTemplate.update( JdbcTemplate.java:849)
at org.springframework.jdbc.core.JdbcTemplate.update( JdbcTemplate.java:853)
at org.springframework.batch.core.repository.dao.Jdbc JobInstanceDao.createJobInstance(JdbcJobInstanceDa o.java:68)
at org.springframework.batch.core.repository.support. SimpleJobRepository.createJobExecution(SimpleJobRe pository.java:180)
at sun.reflect.GeneratedMethodAccessor445.invoke(Unkn own Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:182)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :149)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:106)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.interceptor.ExposeInvocati onInterceptor.invoke(ExposeInvocationInterceptor.j ava:89)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy120.createJobExecution(Unknown Source)
at org.springframework.batch.core.launch.support.Simp leJobLauncher.run(SimpleJobLauncher.java:79)
at com.om.dh.batch.core.ProxyJobBean.runJob(ProxyJobB ean.java:124)
at com.om.dh.batch.core.ProxyJobBean.executeInternal( ProxyJobBean.java:88)
at org.springframework.scheduling.quartz.QuartzJobBea n.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:2 02)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run (SimpleThreadPool.java:529)
Caused by: com.mysql.jdbc.exceptions.MySQLTransactionRollback Exception: Deadlock found when trying to get lock; try restarting transaction
at com.mysql.jdbc.SQLError.createSQLException(SQLErro r.java:1042)
at com.mysql.jdbc.SQLError.createSQLException(SQLErro r.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:3376)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:3308)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:18 37)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java :1961)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionIm pl.java:2543)
at com.mysql.jdbc.PreparedStatement.executeInternal(P reparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.executeUpdate(Pre paredStatement.java:2022)
at com.mysql.jdbc.PreparedStatement.executeUpdate(Pre paredStatement.java:1940)
at com.mysql.jdbc.PreparedStatement.executeUpdate(Pre paredStatement.java:1925)
at org.jboss.resource.adapter.jdbc.CachedPreparedStat ement.executeUpdate(CachedPreparedStatement.java:9 5)
at org.jboss.resource.adapter.jdbc.WrappedPreparedSta tement.executeUpdate(WrappedPreparedStatement.java :251)
at org.springframework.jdbc.core.JdbcTemplate$2.doInP reparedStatement(JdbcTemplate.java:797)
at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:590)
... 23 more
I think we are facing this issue only in 1.0.1. We haven't tested completely in 1.0.0. We used to have lot of jobs even in m4, but we haven't faced this issue. But i might be wrong.

regards,
Ramkris