Skip to content

Commit

Permalink
JBERET-597 skippable exception thrown in ItemWriter triggers new chun…
Browse files Browse the repository at this point in the history
…k within the old transaction
  • Loading branch information
chengfang committed Oct 12, 2023
1 parent 4eb3578 commit cecb409
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 cecb409

Please sign in to comment.