-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: transaction is never committed
PostPosted: Thu Nov 05, 2009 6:36 am 
Newbie

Joined: Wed Nov 04, 2009 9:50 am
Posts: 1
Hello.
We are using Hibernate 3.3.1GA with Jboss 4.2.3GA.
Here is the relevant hibernate configuration:
<hibernate-configuration>
<session-factory name="java:hibernate/SessionFactory">
<!-- properties -->
<property name="connection.datasource">java:toluna_mssql_jdbc</property>
<property name="dialect">com.toluna.common.hibernate.SqlServerDialect</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">
org.hibernate.transaction.JBossTransactionManagerLookup
</property>
<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.transaction.auto_close_session">true</property>
<property name="hibernate.connection.release_mode">after_transaction</property>
<property name="hibernate.connection.defaultNChar">true</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.cache.use_minimal_puts">true</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.max_fetch_depth">1</property>
<property name="hibernate.jdbc.batch_size">250</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.order_updates">true</property>
<property name="hibernate.jdbc.use_streams_for_binary">true</property>
...
Now my problem is that under heavy load I can see transactions that are never committed. As a result these transactions hold db locks forever (at least 1 hour till transaction timeout happens) and the whole system got stuck -- other transactions are waiting for the stucked one to release locks and so eventually Jboss threads are stuck.
I used SQL profiler and found easily the stuck transaction at the head of the waiting chain. There are 400+ SQL commands (most are selects) hanging on this transaction after last commit!
I must mark that without heavy load everything works fine.
Now our common usage of Hibernate session is like this:
We get the session at the Jboss backend when our EJB method is called:

Session s = SessionFactory.getCurrentSession();
s.beginTransaction();
//do EJB business logic
// there can be also s.flush() commands scattered here and there
// there can be local interface calls to other EJBs that have a similar structure as this one (As I know consequent s.beginTransaction() commands are ignored by Hibernate)
return;

As you see we don't do commit and don't close hibernate session and this is probably performed well by Hibernate.
Unless there is a heavy load in which case I suspect that Hibernate "forgets" to perform commit.
I can't add commits before return from every EJB call since there are inter-bean calls too and preliminary commits are very undesired.
Please help.


Top
 Profile  
 
 Post subject: Re: transaction is never committed
PostPosted: Fri Nov 06, 2009 7:10 am 
Newbie

Joined: Fri Nov 06, 2009 7:05 am
Posts: 1
Dont use Hibernate query.Use the db query directly.

It will create n number of objects for n number of rows present in DB. so it will get Hang.

So Use the Database query directly.Do n't use Javaobject queries with hibernate when retrieving more records.


Ex: Select * from employee where emp.rec>=1000

Hope This Helps !

Thanks,
Kannan.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.