Attempt to update step execution id=1 with wrong version (2), where current version is 1

user2583922 picture user2583922 · Jul 16, 2013 · Viewed 15.7k times · Source

Im using SpringBatch 2.1.7 release core and Infrastructure jars to read a CSV file and save it to DB.

Integrated my code with Spring quartz scheduler to run for every minute, The Batch is working fine with reading and writing but its failing with the error "org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=1 with wrong version (2), where current version is 1"

due to Tx conflicts. Please suggest how can i resolve this issue.

Answer

MattC picture MattC · Jun 8, 2015

I had this same exception.

org.springframework.dao.OptimisticLockingFailureException: 
Attempt to update step execution id=0 with wrong version (2), where current version is 3 

In my case, it was caused by a failure the process step, which was being swallowed. Spring Batch activated the writer, even though the processor had failed. Look through your logs to make sure that your process step is completing and returning something.