<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Wed, Sep 18, 2013 at 2:54 PM, Scott Marlow <span dir="ltr"><<a href="mailto:smarlow@redhat.com" target="_blank">smarlow@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">What are the requirements for supporting Batch section 11.6 [1]? From<br>
looking at JSR352, I get that each "chunk" has its own JTA transaction.<br>
I previously had heard that we only supported starting the transaction<br>
from the application processing code (via UserTransaction) but I think<br>
the Batch container/runtime should start a JTA transaction for each<br>
"chunk" that is processed. What are we really doing for managing the<br>
JTA transactions for batch?<br></blockquote><div><br></div><div>The spec says:</div><div><br></div><div><div>8.2.1 Each chunk is processed in a separate transaction. See section 9.7 for more </div><div>details on transactionality.</div>
</div><div><br></div><div>To me that implies the batch implementation starts the transaction itself, although it does seem very vague. For instance looking at those diagrams it looks like the transaction is committed even if an exception is thrown, and it also does not seem to give you any possibility of managing the transaction yourself, or doing non-transactional work. <br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
<br>
REGULAR CHUNK PROCESSING & JPA<br>
<br>
<br>
For the JPA support for regular chunk processing [1], the following will<br>
give a new underlying persistence context per chunk (jta tx):<br>
<br>
@PersistenceContext(unitName = "chunkNonpartitionedAZTT4443334")<br>
EntityManager em;<br>
<br>
<br>
PARTITIONED CHUNK PROCESSING & JPA<br>
<br>
<br>
For the JPA support for partitioned chunk processing [2], the following<br>
will give a new underlying persistence context per chunk (jta tx):<br>
<br>
@PersistenceContext(unitName = "chunkpartitionedAZTT4443334")<br>
EntityManager em;<br>
<br>
One concern that I have about partitioning is the performance impact of<br>
deadlocking and waiting for the JTA transaction to time out. Depending<br>
on whether the work is configured to retry or not, hitting several dead<br>
locks in a batch process could defeat some of the performance gains of<br>
partitioning. Avoiding deadlocks by always reading/writing/locking the<br>
underlying database resources in the same exact order, would help avoid<br>
deadlocks.<br></blockquote><div><br></div><div>IMHO if you are attempting to partition work that results in a deadlock then you are basically doing something wrong. Also, as each chunk should be basically running the same code but with difference data, in general it should acquire locks in the same order anyway. </div>
<div><br></div><div>Stuart</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Beyond the basic JPA capability of ensuring that each "chunk", has its<br>
own persistence context, how else can we help the batch processing<br>
experts writing JSR-352 applications on WildFly/Hibernate?<br>
<br>
Anything else to discuss about JPA & Batch?<br>
<br>
[1] Batch spec section section 11.6 Regular Chunk Processing<br>
<a href="https://gist.github.com/scottmarlow/6603746" target="_blank">https://gist.github.com/scottmarlow/6603746</a><br>
<br>
[2] Batch spec section Batch 11.7 Partitioned Chunk Processing<br>
<a href="https://gist.github.com/scottmarlow/6607667" target="_blank">https://gist.github.com/scottmarlow/6607667</a><br>
<br>
[3] persistence.xml <a href="https://gist.github.com/scottmarlow/6608533" target="_blank">https://gist.github.com/scottmarlow/6608533</a><br>
<br>
_______________________________________________<br>
wildfly-dev mailing list<br>
<a href="mailto:wildfly-dev@lists.jboss.org">wildfly-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/wildfly-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/wildfly-dev</a><br>
</blockquote></div><br></div></div>