Uploaded image for project: 'JBeret'
  1. JBeret
  2. JBERET-179

Item skipping causes JTA exception due to missing transaction rollback

    Details

      Description

      I have a chunk-type step which uses the combined retryable + skippable exception behavior (section 8.2.1.4.3 in the spec). When an exception (caused by a constraint violation on the database) occurs during retry in doCheckpoint() the further flow of control causes a new transaction to be started in ChunkRunner:286. Since the current transaction has not been rollbacked, the following exception is thrown:

      javax.transaction.NotSupportedException: BaseTransaction.checkTransactionState - ARJUNA016051: thread is already associated with a transaction!
              at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.begin(BaseTransaction.java:72)
              at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.begin(BaseTransactionManagerDelegate.java:65)
              at org.jberet.runtime.runner.ChunkRunner.readProcessWriteItems(ChunkRunner.java:286)
              at org.jberet.runtime.runner.ChunkRunner.run(ChunkRunner.java:192)
              at org.wildfly.jberet.services.BatchEnvironmentService$WildFlyBatchEnvironment$1.run(BatchEnvironmentService.java:139)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
              at java.util.concurrent.FutureTask.run(FutureTask.java:266)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
              at java.lang.Thread.run(Thread.java:745)
              at org.jboss.threads.JBossThread.run(JBossThread.java:320)
      Caused by: java.lang.IllegalStateException: BaseTransaction.checkTransactionState - ARJUNA016051: thread is already associated with a transaction!
              at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.checkTransactionState(BaseTransaction.java:262)
              at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.begin(BaseTransaction.java:68)
              ... 10 more
      

      I was able to fix this for now by inserting the following after ChunkRunner:571

      if (tm.getStatus() != Status.STATUS_ACTIVE) {
          tm.rollback();
      }
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  cfang Cheng Fang
                  Reporter:
                  mobe Moritz Becker
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: