Announcement Announcement Module
Collapse
No announcement yet.
OptimisticLockingFailureException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OptimisticLockingFailureException

    Hi,

    I am getting below exception when I ran same job with different job parameters through multiple threads.

    I have a job which will be executed to process a file.
    To process multiple files, I have used threads to execute each File in different thread. where each thread processes a Same job with different job parameters.

    Can someone tell me if I need to do any changes to overcome this exception.
    Or If there is a best approach to handle my scenario.

    Thanks in advance for the response.

    Code:
    org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=0 with wrong version (1), where current version is 2
    	at org.springframework.batch.core.repository.dao.MapJobExecutionDao.updateJobExecution(MapJobExecutionDao.java:93)
    	at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:155)
    	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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy8.update(Unknown Source)
    	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:329)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:114)
    	at com.cme.marketdata.fix2rlc.service.JobExecutorTask.execute(JobExecutorTask.java:63)

  • #2
    The best thing you can do is not use the Map JobRepository. Upgrading to the latest Spring Batch release might also help - there is some measure of thread safety in later version of the map repository, but it still isn't a perfect replacement for the RDBMS.

    Comment


    • #3
      Thanks for the reply Dave.
      When I was using 2.1.2 relase I did not have any issue. When I upgraded to 2.1.3 this exception started.

      Comment


      • #4
        @anish555,

        Is there any reason you would not want to use an in-memory database ( e.g. H2, HSQLDB, Derby, etc.. ) which is 100% thread safe?

        /Anatoly

        Comment


        • #5
          We are mot using Database in our application to get best performance.

          Comment

          Working...
          X