Feb 14th, 2013, 11:28 AM
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.
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.
Mar 8th, 2013, 03:24 AM
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,
Mar 8th, 2013, 10:33 AM
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.
Mar 10th, 2013, 10:40 AM
I created BATCH-1981 for this issue