-->
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.  [ 4 posts ] 
Author Message
 Post subject: beginTransction() takes 30 mins when Informix DB is down
PostPosted: Wed Sep 29, 2010 5:58 pm 
Newbie

Joined: Wed Sep 29, 2010 5:38 pm
Posts: 3
We're using hibernate in our web app, connect to IBM Informix DB. From time to time, when DB is down, it took about 30 mins for beginTransction() to throw the exception back. Our code is like this:

Code:
            logger.trace("before beginTransaction()");               
            transaction=session.beginTransaction();
            logger.trace("after beginTransaction()");                           
            Object result = command(session);
            transaction.commit();
            logger.trace( "after commit()");                                       
            session.close();
            return result;
         } catch (Exception e) {
            if (e instanceof HibernateException) {
               logger.log("DB Runtime Exception thrown from Hibernate Layer", e);



We're using Hibernate 3.2.4, and c3p0 connection pool.

The log stack trace is the following:
Code:
0000000310: 172.27.184.200: Sep 29 2010 10:47:24.889 -0700: %ConfigImplCommand:execute():  {Thrd=pool-8-thread-1}  before beginTransaction()
0000000741: 172.27.184.200: Sep 29 2010 11:15:04.773 -0700: %[exception=org.hibernate.exception.GenericJDBCException: Cannot open connection
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
   at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
   at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
   at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
   at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
   at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
   at com.....ConfigImplCommand.execute(ConfigImplCommand.java:64)
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
   at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
   at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)
   at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
   at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:56)
   at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
   ... 16 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
   at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
   at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
   at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
   at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)


Your kind help will be highly appreciated!


Top
 Profile  
 
 Post subject: Re: beginTransction() takes 30 mins when Informix DB is down
PostPosted: Wed Sep 29, 2010 6:32 pm 
Beginner
Beginner

Joined: Fri Mar 11, 2005 7:46 am
Posts: 29
have a look here: http://community.jboss.org/wiki/HowToco ... ectionpool


Top
 Profile  
 
 Post subject: Re: beginTransction() takes 30 mins when Informix DB is down
PostPosted: Wed Sep 29, 2010 6:43 pm 
Newbie

Joined: Wed Sep 29, 2010 5:38 pm
Posts: 3
Thanks for your reply, I was reading that link when I got your reply :-). I verified on my hibernate config file, the timeout value is 30 minutes:
Code:
<property name="hibernate.c3p0.timeout">1800</property> <!-- seconds -->


by reading the c3p0 config link you pointed out, the timeout value means:
Quote:
Seconds a Connection can remain pooled but unused before being discarded.
. How is that related to the issue we encountered?

I read this link: http://www.mchange.com/projects/c3p0/index.html#maxIdleTime, it's saying to set timeout to 1800 secs is pretty aggressive already, what would be the recommended value then?


Top
 Profile  
 
 Post subject: Re: beginTransction() takes 30 mins when Informix DB is down
PostPosted: Wed Sep 29, 2010 8:28 pm 
Beginner
Beginner

Joined: Fri Mar 11, 2005 7:46 am
Posts: 29
I am not sure how exactly the pool mechanism works - best to have a look at source code. You can probably use idleConnectionTestPeriod to periodically verify connection is alive.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.