1

On JSR-352 batch, I'm defining a transaction timeout in step level for chunk processing as 900s. At the same time I have transaction timeout mentioned in server.xml as 1800s. this chunk processing step is partitioned using PartitionMapper step. My question is when the step gets executed, few threads getting timed out using step level transaction timeout which is 900s. But few threads hanging for while and getting timed out based on server.xml transaction timeout which is 1800s.

<step id="ReportBatch" >
    <properties >
        <property name="javax.transaction.global.timeout" value="900"/>
    </properties></step>

server.xml
<transaction clientInactivityTimeout="1800" propogatedOrBMTTranLifetimeTimeout="1800" totalTranLifetimeTimeout="1800" transactionLogDirectory="${server.config.dir}/tranlog/"/>

I'm expecting thread should fail with 900s timeout mentioned in step level. Which transaction timeout takes the preference ? Is this fine to remove transaction time out from server.xml, or reduce the timeout limit on server.xml

user3540722
  • 175
  • 1
  • 2
  • 11
  • 1
    I tried to cover the subject in [this post](https://stackoverflow.com/questions/36945450/how-do-i-configure-a-transaction-timeout-in-websphere-liberty-batch). Please see if it answers your question. – Scott Kurz Jan 22 '19 at 16:33
  • Based on the above post and from ibm link, This timeout is used only if the application component does not set its own transaction timeout. But in my case, I could see different behavior, as mentioned few threads using application specified timeout which is step level. few threads uses server specified timeout. that's where my confusion – user3540722 Jan 22 '19 at 17:16
  • And I have maxIdletime as well. will this have any impact ? – user3540722 Jan 22 '19 at 17:17
  • 1
    OK, you're absolutely right, the "javax.transaction.global.timeout" step property timeout provides the application timeout, which should constrain the chunk transaction, even for the partitioned thread. I would expect your partition threads timeout after 900s then, unless you are doing something on your own like suspending and starting some other transaction from the partition threads. If you can post a stack trace of one of the threads timing out after 1800s I will take a look. – Scott Kurz Jan 22 '19 at 17:58
  • Additionally I'm getting below error, when the reader not able to read the resultset(due to the performance of the query). It's failing with the below error. CWWKY0024W: The current chunk was rolled back to the previous checkpoint for step genReport in job instance 227,001 and job execution 227,002. Step metrics = [(READ_SKIP_COUNT,0), (PROCESS_SKIP_COUNT,0), (WRITE_SKIP_COUNT,0), (FILTER_COUNT,0), (COMMIT_COUNT,0), (READ_COUNT,0), (WRITE_COUNT,0), (ROLLBACK_COUNT,0)] How to handle this error, Do I need to set query timeout on statement object. – user3540722 Jan 23 '19 at 18:12
  • OK, I think you may have wrongly expected the tran timeout to immediately result in a failure on that thread. I added an answer which explains that this is not the case. If you have a question about how to use query timeout on the JDBC Statement, that's really a more general question than a batch one, so I think that would be better as a separate question after including sample code. That said, it seems to me like it might be a direction worth exploring though. – Scott Kurz Jan 23 '19 at 18:41

1 Answers1

2

Configuring transaction timeout

Yes, the step property javax.transaction.global.timeout" sets the transaction timeout for the partition-level threads executing "chunks" within a partitioned chunk step just as you had in the job XML (JSL) snippet:

<step id="ReportBatch" >
    <properties >
        <property name="javax.transaction.global.timeout" value="900"/>
    </properties>
    <chunk>...</chunk>
    <partition>...</partition>
</step>

The server configuration can set an upper bound for these "application" transaction timeouts via:

<transaction propogatedOrBMTTranLifetimeTimeout="1800s"/>

So with the above example, the effective tran timeout for your chunk transactions would be 900s.

This is detailed, along with a few other options in this question and answer.

What happens in a transaction timeout

When a transaction times out, the transaction is immediately marked for rollback, and a message appears in the messages.log along with details of the relevant thread, including a stack trace.

However, your application might not notice right away. If it is "hung" making a call over the network or doing a CPU-intensive calculation, it will continue on, and may only see an exception thrown when it touches a transactional resource, or checks the status of the transaction, etc.

Scott Kurz
  • 4,985
  • 1
  • 18
  • 40
  • You are right, When the transaction gets timedout it marked for Rollback. Below is the error message from messages.log. Is there way to catch the below exception. The catch block (Exception e) does not seems to be catching the below exception. And Its forwarding to ChunkStepControllerImpl to call the close() methods of writer and reader. – user3540722 Jan 23 '19 at 19:28
  • com.ibm.tx.jta.embeddable.impl.EmbeddableTimeoutManager I WTRN0006W: Transaction 000001687C0F80A600000001702D925054D55D870490BCF110A06AF846023110AA52D81C000001687C0F80A600000001702D925054D55D870490BCF110A06AF846023110AA52D81C00000001 has timed out after 900 seconds. [1/23/19 14:08:37:336 EST] 0000009b com.ibm.tx.jta.embeddable.impl.EmbeddableTimeoutManager I WTRN0124I: When the timeout occurred the thread with which the transaction is, or was most recently, associated was Thread[Default Executor-thread-90,5,Default Executor Thread Group]. – user3540722 Jan 23 '19 at 19:29
  • The **WTRN0006W** plus **WTRN0124I** messages show a stack traces of the thread timing out but this stack trace is not an exception stack trace. If you have a question about how to write Java code to deal with this I'd suggest creating a new question and including sample Java code with the relevant details. – Scott Kurz Jan 23 '19 at 19:34