diff --git a/jberet-core/src/main/java/org/jberet/runtime/runner/ChunkRunner.java b/jberet-core/src/main/java/org/jberet/runtime/runner/ChunkRunner.java index ad89bb1c9..55e25bf30 100644 --- a/jberet-core/src/main/java/org/jberet/runtime/runner/ChunkRunner.java +++ b/jberet-core/src/main/java/org/jberet/runtime/runner/ChunkRunner.java @@ -642,7 +642,12 @@ private void doCheckpoint(final ProcessingInfo processingInfo) throws Exception //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) { + // + //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(); }