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

Batch thread tx context not cleaned up properly on tx timeout in chunk-type step

    XMLWordPrintable

Details

    • Hide

      I have attached a project that can be used to reproduce the issue. To do so, follow these steps:

      • In the Wildfly standalone.xml reduce the batch thread count to 1
      • Package and deploy the war
      • Execute HTTP GET http://localhost:8080/start (this will start a batch job causing a transaction timeout after 5 seconds)
      • Execute HTTP GET http://localhost:8080/start one more time and note that the job fails when attempting to start a transaction
      Show
      I have attached a project that can be used to reproduce the issue. To do so, follow these steps: In the Wildfly standalone.xml reduce the batch thread count to 1 Package and deploy the war Execute HTTP GET http://localhost:8080/start (this will start a batch job causing a transaction timeout after 5 seconds) Execute HTTP GET http://localhost:8080/start one more time and note that the job fails when attempting to start a transaction

    Description

      When a transaction timeout occurs in a batch thread running a chunk-type step, the transaction context does not seem to be cleaned up properly. New chunk-type steps cannot be started on the respective thread any more - a server restart is required.

      Following exception is thrown when trying to run a chunk-type step in a batch thread that experienced a tx timeout before:

      12:10:48,070 INFO  [org.jberet.test.StepBoundaryLogger] (Batch Thread - 1) Starting job job
      12:10:48,071 INFO  [org.jberet.test.StepBoundaryLogger] (Batch Thread - 1) Starting step jobStep
      12:10:48,072 TRACE [com.arjuna.ats.jta] (Batch Thread - 1) BaseTransaction.begin
      12:10:48,072 TRACE [com.arjuna.ats.jta] (Batch Thread - 1) TransactionImple.getStatus: javax.transaction.Status.STATUS_ROLLEDBACK
      12:10:48,076 ERROR [org.jberet] (Batch Thread - 1) item-count=20, time-limit=0, skip-limit=-1, skipCount=0, retry-limit=-1, retryCount=0
      12:10:48,076 ERROR [org.jberet] (Batch Thread - 1) JBERET000007: Failed to run job job, jobStep, org.jberet.job.model.Chunk@3a5ab142: 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:73)
      	at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.begin(BaseTransactionManagerDelegate.java:78)
      	at org.jberet.runtime.runner.ChunkRunner.run(ChunkRunner.java:187)
      	at org.jberet.runtime.runner.StepExecutionRunner.runBatchletOrChunk(StepExecutionRunner.java:219)
      	at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:140)
      	at org.jberet.runtime.runner.CompositeExecutionRunner.runStep(CompositeExecutionRunner.java:164)
      	at org.jberet.runtime.runner.CompositeExecutionRunner.runFromHeadOrRestartPoint(CompositeExecutionRunner.java:88)
      	at org.jberet.runtime.runner.JobExecutionRunner.run(JobExecutionRunner.java:59)
      	at org.wildfly.extension.batch.jberet.impl.BatchEnvironmentService$WildFlyBatchEnvironment$1.run(BatchEnvironmentService.java:243)
      	at org.wildfly.extension.requestcontroller.RequestController$QueuedTask$1.run(RequestController.java:497)
      	at org.jberet.spi.JobExecutor$3.run(JobExecutor.java:161)
      	at org.jberet.spi.JobExecutor$1.run(JobExecutor.java:99)
      	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:264)
      	at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.begin(BaseTransaction.java:68)
      	... 15 more
      
      12:10:48,077 INFO  [org.jberet.test.StepBoundaryLogger] (Batch Thread - 1) Step jobStep finished
      12:10:48,077 INFO  [org.jberet.test.StepBoundaryLogger] (Batch Thread - 1) Job job finished
      

      Attachments

        Issue Links

          Activity

            People

              cfang@redhat.com Cheng Fang
              moritz.becker@gmx.at Moritz Becker (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: