Results 1 to 5 of 5

Thread: OptimisticLockingFailureException

  1. #1
    Join Date
    Jul 2010
    Location
    USA
    Posts
    43

    Default 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. #2
    Join Date
    Jun 2005
    Posts
    4,231

    Default

    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.

  3. #3
    Join Date
    Jul 2010
    Location
    USA
    Posts
    43

    Default

    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.

  4. #4
    Join Date
    Apr 2008
    Location
    Philadelphia, US
    Posts
    198

    Arrow

    @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
    Humans are stateful and mutable beings that have no problems processing many things concurrently and share state with others + they are usually "coupled"

  5. #5
    Join Date
    Jul 2010
    Location
    USA
    Posts
    43

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •