my dog learned polymorphism*
The moose likes Spring and the fly likes Spring Batch: Commit-Interval not honored after roll back during write Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring Batch: Commit-Interval not honored after roll back during write " Watch "Spring Batch: Commit-Interval not honored after roll back during write " New topic
Author

Spring Batch: Commit-Interval not honored after roll back during write

vicky chauhan
Ranch Hand

Joined: Nov 27, 2008
Posts: 41
Hello All,

Say my commit interval is 1000.

And during writing I get a error at 990th record which is skippable as per skip policy.

So a rollback will occur and the writer will start again writing the same records from record 1.

However, this time, It is commiting on each record. It does not honour commit interval. This is making the job dead slow.

Why the behavior is like that ?? Am I missing something in my configuration ??

Thanks.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

My question is why does it rollback at all. If you policy is to skip records when an error occurs, to me means, any error, skip and continue on where you left off. Not go back to the first record.

Maybe your configuration for skip or transactions is off. I don't know much more about Spring Batch.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
vicky chauhan
Ranch Hand

Joined: Nov 27, 2008
Posts: 41
Mark Spritzler wrote:My question is why does it rollback at all. If you policy is to skip records when an error occurs, to me means, any error, skip and continue on where you left off. Not go back to the first record.

Maybe your configuration for skip or transactions is off. I don't know much more about Spring Batch.

Mark


Hello Mark,

Thanks for the input!!

Spring batch writes to database in chunk/batch -- like 100 records at a time... So in case of an exception, it does not know which item of the 100 resulted in exception... So for the skip policy to work, it rolls back and starts over writing each item at a time... So that the item where error occurred is caught...

My question is, once the item is found, the rest of the items should again be written off as a batch...... which is not happening........

Say there are 1000 records, and error occurred at 4th record.. so once the 4th item is found, the remaining 996 records should be written as a chunk instead of one at a time...

I don't know any configuration is available to make this possible or whether this behavior is missing from spring batch!!

Nik
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Ah. well if it is doing that, then I recommend opening up a Jira ticket for that at SpringSource for the Batch project.

I actually would first post your question in the Spring Batch forum at http://forum.springsource.org/forumdisplay.php?41-Batch

This way they can tell you if it is a bug or a feature, then if it is a bug, put it into their jira.

Thanks

Mark
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Spring Batch: Commit-Interval not honored after roll back during write