Note that there are some explanatory texts on larger screens.

plurals
  1. POEJB transactions slowing down in one thread
    text
    copied!<p>I have a performance problem with my process. It's an asynchronous task launched in CMT bean (on jboss server).</p> <p>1 iteration performs 1 update and 3 inserts to my db via Hibernate. The process is divided into new transactions every 100 iterations.</p> <p>Flush is called on EntityManager after every update/insert.</p> <p>While the starting performance of first batch is satisfying (around 5-8s) it slows down drastically with time. The 30th batch takes around 30s to finish and later grows up to over 2 minutes per batch.</p> <p>I tried switching FlushModeType to COMMIT, manual clearing/closing entityManagers, clearing entityManagers cache, I looked for memory leaks and can't find the reason for this slow down. </p> <p>I measured little bits of code execution time and every code involving database connection slows down with time. I understand that a transaction slows with more entities processed but why is new transaction also slower?</p> <p>The latest process consists of 250 000 iterations (2500 transactions in 1 thread) and takes forever to end. </p> <p>If needed I'll provide more information. Any help would be appreciated.</p> <p>I tried simplifying this code just to do 1 hibernate insert and no other operations and it still slows with time. This is an abstract pseudo view of what's going on inside. </p> <pre><code>Bean1 @Asynchronous @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void mainTask(){ while(...){ subTask(); } } Bean2 @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void subTask(){ 100.times{ 3*Insert 1*Update } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload