Announcement Announcement Module
Collapse
No announcement yet.
OptimisticLockingFailureException when stop the job at its ending stage Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OptimisticLockingFailureException when stop the job at its ending stage

    I have a spring batch job running in asynchronous mode and issue the stop operation through JobOperator in a virgo OSGi container. OptimisticLockingFailureException can be thrown if the job is at the last moment to update the JobExecution status to COMPLETED because it detects the version conflicts.

    I noticed two related Jira issues were opened.
    https://jira.springsource.org/browse/BATCH-954
    https://jira.springsource.org/browse/BATCHADM-135

    The first issue had been resolved since 2.0.0.M4 but I am using 2.1.8.RELEASE.
    The second issue reported similar problem when the job is at STARTING status. It is still open.

    Is my problem a valid issue? Any solution already? Thanks.

    Robert commented in BATCH-954 back in 2008
    "JobOperator works with its own copy of JobExecution therefore the version mismatch between job's and jobOperators' version is inevitable. This issue fixed the obvious problem (when jobOperator updates the status, job's version becomes obsolete), but I think there can still be trouble with race conditions. I want to take a closer look at this in BATCH-961"

    Is this really inevitable? Then what is the best practice to stop a job running asynchronous mode? Thanks again.

  • #2
    Hello, I've got the same problem when trying to stop running batches with the SimpleJobOperator through JMX, as in BATCH-954, in asynchronous mode like weibill, with a 2.1.9.RELEASE.

    Have you got a solution for this, or is it linked to the old bug in BATCH-954?

    Thanks in advance,

    Ben

    Comment


    • #3
      Do you have a stack trace from that exception or a unit test that reliably recreates it? I may have a solution...

      Either way, a Jira ticket should be opened for this.

      Comment


      • #4
        I created BATCH-1981 for this issue

        Comment


        • #5
          Has anyone done anything with this please? I have exactly the same problem, where i have started the Job in an asynchronous launcher and now coming to manually stop it and the OptimisticLock exception is thrown!

          Comment


          • #6
            @MInella here is a stack trace for you on this, i am using the 2.1.9-RELEASE of spring batch as well

            Code:
            org.springframework.dao.OptimisticLockingFailureException: Attempt to update job execution id=11 with wrong version (0), where current version is 1
            	at org.springframework.batch.core.repository.dao.JdbcJobExecutionDao.updateJobExecution(JdbcJobExecutionDao.java:210)
            	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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
            	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
            	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
            	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
            	at $Proxy118.update(Unknown Source)
            	at org.springframework.batch.core.launch.support.SimpleJobOperator.stop(SimpleJobOperator.java:380)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
            	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
            	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
            	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
            	at $Proxy119.stop(Unknown Source)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
            	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
            	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
            	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
            	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
            	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
            	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
            	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
            	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
            	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
            	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
            	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
            	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
            	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
            	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
            	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
            	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
            	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
            	at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
            	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
            	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
            	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
            Last edited by IanB; May 22nd, 2013, 03:15 AM.

            Comment

            Working...
            X