-->
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: Connection pooling issues in c3p0
PostPosted: Sun Mar 18, 2007 4:55 pm 
Newbie

Joined: Thu Feb 22, 2007 12:22 am
Posts: 1
I am using a combination of hibernate and jdbc for persistence. I am having a problem with application hang or running out of connections during stress testing.Our hibernate.cfg.xml contains the following settings:

<property name="hibernate.c3p0.timeout">0</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.min_size">1</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.c3p0.idle_test_period">540</property>
<property name="hibernate.c3p0.validate">true</property>

Initially, I was using c3p0-0.9.0.jar. After I do a lookup for an object about 10 times, my application would hang and finally terminate with an exception that I have run out of connections. After some research, I found that it is advisable to use c3p0-0.9.1.jar. After I switched over to using this version of the jar file, I dont see the exception any more but the application either hangs or takes a long time to acquire a connection. While using JDBC, I get a connection through hibernate and finally return it (by closing it) after I have done with it. Has anyone seen this problem? Does my configuration look right?

Any and all help will be appreciated


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 25, 2007 7:17 am 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
Are you sure you're not leaking Connections somewhere?

Try setting c3p0-0.9.1's unreturnedConnectionTimeout and debugUnreturnedConnectionStackTraces properties (in a c3p0.properties file for hibernate < 3.2.2, in a c3p0.properties file or your hibernate config for hibernate 3.2.2+, please verify that your settings have taken effect by looking at c3p0's config dump in your logs). If you see unreturnedConnections timing out, then there is likely some circumstance in which you are somehow not closing a Connection. If debugUnreturnedConnectionStackTraces is true, you'll see stack traces showing how the unreturned Connections were originally checked out, giving you a strong clue about where you need to tighten up Connection cleanup.)

Of course, your clean-up may be fine, and your problem may be something else entirely. But indefinite hangs after a reliable first bunch of Connections sounds a lot some of that first bunch of Connections didn't get closed.

If you have access to JMX, you might check whether the number of busy Connections is the same as maxPoolSize when your application hangs. If you don't, messing around with different settings of maxPoolSize might help: if there is a resource leak, then the smaller maxPoolSize, the more quickly your app will hang.

Good luck!
Steve


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.