5

I am getting Commit failed while step execution data was already updated error when spring batch try to commit the records. Any help would be greatly appreciated. I am using HIbernate JPA .

It is working for lesser number of records. Throwing error when the record count is high.

Stack Trace:

2016-01-20 08:49:45 INFO  TaskletStep:359 - Commit failed while step execution data was already updated. Reverting to old version.
2016-01-20 08:49:45 ERROR TaskletStep:370 - Rolling back with transaction in unknown state
2016-01-20 08:49:45 ERROR AbstractStep:225 - Encountered an error executing  step uploadFiles in job fileUploadJob
org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException:  Transaction marked as rollbackOnly
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:524)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:757)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:726)
Nitish Kumar
  • 721
  • 1
  • 10
  • 26
Gopi
  • 619
  • 2
  • 9
  • 27
  • Do you have some component marked with @Transactional? Usually it is the source of transaction problems – Luca Basso Ricci Jan 20 '16 at 15:33
  • Thank you for reply. I dont have @Transactional anywhere in my code. It is working when i setted the commit interval to 1 .if i setted to 100 or 1000 or 10000 it is failing. – Gopi Jan 21 '16 at 11:00

1 Answers1

5

I had same error "Commit failed while step execution data was already updated. Reverting to old version" and I solved it by using " @Transactional(propagation = Propagation.REQUIRES_NEW)" annotation above the method where the records were committed.

Rakesh Gurung
  • 85
  • 2
  • 9