org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=50 with wrong version (12), where current version is 13

Spring JIRA | Gaurang | 1 year ago
  1. 0

    Hi, I am working on trying to solve this issue since last 3 weeks. It is a blocker issue because it is stopping us from using spring batch as ETL solution for our project. We are using partition oriented processing for partitioning large files into step executions. Each step execution will then use Chunk oriented processing to read, process and write data based on the start & end index in the execution context. If I run the process with just 1 partition the process completes without any exception (which means there is no issue with the application code - reader, processor & writer). The process starts failing the moment I add more partitions or even increase the number of threads in the chunk's task executor (tried both ThreadPoolExecutor and org.springframework.core.task.SimpleAsyncTaskExecutor). I am also catching Throwable everywhere and I don't see any exception thrown by any code except the one reported below. Out of say 100 partitions, the process starts throwing this exception after processing approximately 60 partitions. On job repository I tried SERIALIZABLE, READ_COMMITTED isolation levels but that also did not work. Changing the database from PostgresSQL to Oracle did not help. I have looked at all the comments on bugs reported by other users with similar issue and tried everything. Please let me know if you need any other information logs, configuration files, etc. Appreciate your help and response. *+Exception:+* {code:java} 2015-08-12 20:55:04 ERROR o.s.b.c.s.t.TaskletStep:[SimpleAsyncTaskExecutor-14]:458 - JobRepository failure forcing rollback org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=50 with wrong version (12), where current version is 13 at org.springframework.batch.core.repository.dao.JdbcStepExecutionDao.updateStepExecution(JdbcStepExecutionDao.java:255) ~[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:191) ~[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source) ~[na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.7.0_79] at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.7.0_79] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) ~[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at com.sun.proxy.$Proxy102.update(Unknown Source) ~[na:na] at sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source) ~[na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.7.0_79] at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.7.0_79] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127) ~[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at com.sun.proxy.$Proxy58.update(Unknown Source) ~[na:na] at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:452) [spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330) [spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) [spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271) [spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:77) [spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.springframework.batch.repeat.support.TaskExecutorRepeatTemplate$ExecutingRunnable.run(TaskExecutorRepeatTemplate.java:262) [spring-batch-infrastructure-3.0.3.RELEASE.jar:3.0.3.RELEASE] at java.lang.Thread.run(Unknown Source) [na:1.7.0_79] {code}

    Spring JIRA | 1 year ago | Gaurang
    org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=50 with wrong version (12), where current version is 13
  2. 0

    Hi, I am working on trying to solve this issue since last 3 weeks. It is a blocker issue because it is stopping us from using spring batch as ETL solution for our project. We are using partition oriented processing for partitioning large files into step executions. Each step execution will then use Chunk oriented processing to read, process and write data based on the start & end index in the execution context. If I run the process with just 1 partition the process completes without any exception (which means there is no issue with the application code - reader, processor & writer). The process starts failing the moment I add more partitions or even increase the number of threads in the chunk's task executor (tried both ThreadPoolExecutor and org.springframework.core.task.SimpleAsyncTaskExecutor). I am also catching Throwable everywhere and I don't see any exception thrown by any code except the one reported below. Out of say 100 partitions, the process starts throwing this exception after processing approximately 60 partitions. On job repository I tried SERIALIZABLE, READ_COMMITTED isolation levels but that also did not work. Changing the database from PostgresSQL to Oracle did not help. I have looked at all the comments on bugs reported by other users with similar issue and tried everything. Please let me know if you need any other information logs, configuration files, etc. Appreciate your help and response. *+Exception:+* {code:java} 2015-08-12 20:55:04 ERROR o.s.b.c.s.t.TaskletStep:[SimpleAsyncTaskExecutor-14]:458 - JobRepository failure forcing rollback org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=50 with wrong version (12), where current version is 13 at org.springframework.batch.core.repository.dao.JdbcStepExecutionDao.updateStepExecution(JdbcStepExecutionDao.java:255) ~[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:191) ~[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source) ~[na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.7.0_79] at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.7.0_79] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) ~[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at com.sun.proxy.$Proxy102.update(Unknown Source) ~[na:na] at sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source) ~[na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.7.0_79] at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.7.0_79] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127) ~[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE] at com.sun.proxy.$Proxy58.update(Unknown Source) ~[na:na] at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:452) [spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330) [spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) [spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271) [spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:77) [spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.springframework.batch.repeat.support.TaskExecutorRepeatTemplate$ExecutingRunnable.run(TaskExecutorRepeatTemplate.java:262) [spring-batch-infrastructure-3.0.3.RELEASE.jar:3.0.3.RELEASE] at java.lang.Thread.run(Unknown Source) [na:1.7.0_79] {code}

    Spring JIRA | 1 year ago | Gaurang
    org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=50 with wrong version (12), where current version is 13
  3. 0

    Commit failed while step execution data was already updated. Reverting to old version. - Spring batch

    Stack Overflow | 2 years ago | user3839699
    org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=1 with wrong version (1), where current version is 2
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Spring Batch - Parallel Processing - Split flow

    Stack Overflow | 2 years ago | chandra
    org.springframework.batch.core.step.AbstractStep$FatalException: Fatal failure detected
  6. 0

    Hibernate proxy error occurred launch job in Spring Batch

    Stack Overflow | 4 years ago | user1482222
    org.springframework.dao.OptimisticLockingFailureException: Attempt to update job execution id=33 with wrong version (0), where current version is 1

  1. Tahir 141 times, last 3 months ago
2 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.springframework.dao.OptimisticLockingFailureException

    Attempt to update step execution id=50 with wrong version (12), where current version is 13

    at org.springframework.batch.core.repository.dao.JdbcStepExecutionDao.updateStepExecution()
  2. Spring Batch Core
    SimpleJobRepository.update
    1. org.springframework.batch.core.repository.dao.JdbcStepExecutionDao.updateStepExecution(JdbcStepExecutionDao.java:255)[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE]
    2. org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:191)[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE]
    2 frames
  3. Java RT
    Method.invoke
    1. sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source)[na:na]
    2. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)[na:1.7.0_79]
    3. java.lang.reflect.Method.invoke(Unknown Source)[na:1.7.0_79]
    3 frames
  4. Spring AOP
    ReflectiveMethodInvocation.proceed
    1. org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    2. org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    3 frames
  5. Spring Tx
    TransactionInterceptor.invoke
    1. org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    2. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    3. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    3 frames
  6. Spring AOP
    JdkDynamicAopProxy.invoke
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    2 frames
  7. com.sun.proxy
    $Proxy102.update
    1. com.sun.proxy.$Proxy102.update(Unknown Source)[na:na]
    1 frame
  8. Java RT
    Method.invoke
    1. sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source)[na:na]
    2. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)[na:1.7.0_79]
    3. java.lang.reflect.Method.invoke(Unknown Source)[na:1.7.0_79]
    3 frames
  9. Spring AOP
    ReflectiveMethodInvocation.proceed
    1. org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    2. org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    3 frames
  10. Spring Batch Core
    SimpleBatchConfiguration$PassthruAdvice.invoke
    1. org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127)[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE]
    1 frame
  11. Spring AOP
    JdkDynamicAopProxy.invoke
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    2 frames
  12. com.sun.proxy
    $Proxy58.update
    1. com.sun.proxy.$Proxy58.update(Unknown Source)[na:na]
    1 frame
  13. Spring Batch Core
    TaskletStep$ChunkTransactionCallback.doInTransaction
    1. org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:452)[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE]
    2. org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE]
    2 frames
  14. Spring Tx
    TransactionTemplate.execute
    1. org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    1 frame
  15. Spring Batch Core
    StepContextRepeatCallback.doInIteration
    1. org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271)[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE]
    2. org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:77)[spring-batch-core-3.0.3.RELEASE.jar:3.0.3.RELEASE]
    2 frames
  16. Spring Batch Infrastructure
    TaskExecutorRepeatTemplate$ExecutingRunnable.run
    1. org.springframework.batch.repeat.support.TaskExecutorRepeatTemplate$ExecutingRunnable.run(TaskExecutorRepeatTemplate.java:262)[spring-batch-infrastructure-3.0.3.RELEASE.jar:3.0.3.RELEASE]
    1 frame
  17. Java RT
    Thread.run
    1. java.lang.Thread.run(Unknown Source)[na:1.7.0_79]
    1 frame