-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate C3PO C3P0 database connection pool question
PostPosted: Sun Feb 18, 2007 6:54 pm 
Regular
Regular

Joined: Sat Jan 22, 2005 6:57 pm
Posts: 50
Location: Chicago
100 threads are concurrently querying the database with the same query.
Each thread gets a hibernate session independently of the other sessions (via the standard ThreadLocal.get() lookup followed by a sessionFactory.openSession() if its not there) and closes it in its finally block.

On each thread, I time how long it takes for the criteria.list() method to return. Without C3P0 in the configuration file, I notice that the wait times for each thread's criteria.list() call grow exponentially from milliseconds to up to 30 seconds for the final thread.

So it would appear that two threads cannot call criteria.list() at the same time within the same JVM? Is this true? If not... read on...

Figuring it may have something to do with used up connections from my 100 concurrent threads, I turned on C3P0 with a connection pool of 100. Re-ran my test, and the same exact thing happened with nearly the same numbers.

What am I missing here? (I am using MySQL)

Code:
in my hibernate.cfg.xml file:

      <property name="c3p0.acquire_increment">1</property>
      <property name="c3p0.idle_test_period">100</property>
      <property name="c3p0.max_size">10</property>
      <property name="c3p0.max_statements">10</property>
      <property name="c3p0.min_size">10</property>
      <property name="c3p0.timeout">100</property>


Is this sort of FIFO behavior expected on a criteria.list() regardless of how many sessions are calling it?

Thank you in advance.
Mark


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

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.