Skip to content

Commit

Permalink
Merge pull request #381 from chengfang/skippable.exception.JBERET-597
Browse files Browse the repository at this point in the history
JBERET-597 skippable exception thrown in ItemWriter triggers new chun…
  • Loading branch information
liweinan committed Oct 17, 2023
2 parents 391cb03 + cecb409 commit 5adcabd
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -640,9 +640,13 @@ private void doCheckpoint(final ProcessingInfo processingInfo) throws Exception
stepOrPartitionExecution.setReaderCheckpointInfo(itemReader.checkpointInfo());
stepOrPartitionExecution.setWriterCheckpointInfo(itemWriter.checkpointInfo());

//usually the transaction should not be rolled back upon skippable exception, but if the transaction
//is marked rollback only by other parties, it's no longer usable and so roll it back.
if (tm.getStatus() == Status.STATUS_MARKED_ROLLBACK || tm.getStatus() == Status.STATUS_ROLLEDBACK) {
//If the transaction is marked rollback only by other parties, it's no longer usable so roll it back.
//
//JBERET-597 (skippable exception thrown in ItemWriter triggers new chunk within the old transaction)
//The skippable exception is from ItemWriter so the current chunk will be skipped.
//There is no reason to keep active transactions as they may linger around after this skipped chunk.
if (tm.getStatus() == Status.STATUS_ACTIVE ||
tm.getStatus() == Status.STATUS_MARKED_ROLLBACK || tm.getStatus() == Status.STATUS_ROLLEDBACK) {
tm.rollback();
}

Expand Down

0 comments on commit 5adcabd

Please sign in to comment.