-->
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.  [ 6 posts ] 
Author Message
 Post subject: C3P0 Problem
PostPosted: Tue May 31, 2005 9:41 am 
Newbie

Joined: Tue May 17, 2005 8:55 am
Posts: 11
Hi,

I'm doing some load-testing again. When I'm running two jmeter clients after a time all 200 tomcat threads are blocked. When i connect to the server via jconsole i can see that there a lot threads like these are still running and they aren't stopped again:

Code:
Name: http-8080-Processor147
State: WAITING on com.mchange.v2.resourcepool.BasicResourcePool@e4c6320
Total blocked: 1.089  Total waited: 512

Stack trace:
java.lang.Object.wait(Native Method)
com.mchange.v2.resourcepool.BasicResourcePool.awaitAcquire(BasicResourcePool.java:951)
com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:208)
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:232)
com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)
com.mchange.v2.c3p0.ComboPooledDataSource.getConnection(ComboPooledDataSource.java:521)



Name: http-8080-Processor145
State: WAITING on com.mchange.v2.resourcepool.BasicResourcePool@e4c6320
Total blocked: 86  Total waited: 167

Stack trace:
java.lang.Object.wait(Native Method)
com.mchange.v2.resourcepool.BasicResourcePool.awaitAcquire(BasicResourcePool.java:951)
com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:208)
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:232)
com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)
com.mchange.v2.c3p0.ComboPooledDataSource.getConnection(ComboPooledDataSource.java:521)



Version: c3p0-0.9.0-pre6
Java: 1.5 (HP-UX)



C3P0 Parameter:
Code:
com.mchange.v2.c3p0.PoolBackedDataSource     - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource@187f9f1[ acquireIncrement -> 5, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 187f9f1, idleConnectionTestPeriod -> 10, initialPoolSize -> 10, jdbcUrl -> jdbc:oracle:thin:@mhmuhkt2:1521:DWKT2, loginTimeout -> 0, maxIdleTime -> 0, maxPoolSize -> 100, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, numHelperThreads -> 15, preferredTestQuery -> Select 1 from dual, properties -> {user=******, password=******}, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> true, usesTraditionalReflectiveProxies -> false ] --



Are this problems caused by my app, or the connection-pool?

Thx in advance!

blunted


Top
 Profile  
 
 Post subject: some more news
PostPosted: Tue May 31, 2005 10:05 am 
Newbie

Joined: Tue May 17, 2005 8:55 am
Posts: 11
After a hour passend an nothing happend now this log-ouptut came out:


Code:
2005-05-31 16:01:45,566 WARN  com.mchange.v2.async.ThreadPoolAsynchronousRunner     - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@6bce4923 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! --
2005-05-31 16:01:45,567 WARN  com.mchange.v2.async.ThreadPoolAsynchronousRunner     - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@6bce4923 -- APPARENT DEADLOCK!!! Complete Status: [num_managed_threads: 15, num_active: 15; activeTasks: com.mchange.v2.resourcepool.BasicResourcePool$5@1b34ff9e (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2), com.mchange.v2.resourcepool.BasicResourcePool$5@3479ec06 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#8), com.mchange.v2.resourcepool.BasicResourcePool$5@307698d4 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#3), com.mchange.v2.resourcepool.BasicResourcePool$5@3a2b9f27 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#4), com.mchange.v2.resourcepool.BasicResourcePool$5@5ddd747 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#10), com.mchange.v2.resourcepool.BasicResourcePool$5@27607953 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#6), com.mchange.v2.resourcepool.BasicResourcePool$5@2ebd4c57 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#7), com.mchange.v2.resourcepool.BasicResourcePool$5@ddefbba (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#14), com.mchange.v2.resourcepool.BasicResourcePool$5@2a607773 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#12), com.mchange.v2.resourcepool.BasicResourcePool$5@234234c1 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1), com.mchange.v2.resourcepool.BasicResourcePool$5@4f957cfc (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#13), com.mchange.v2.resourcepool.BasicResourcePool$5@5f40ad35 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#11), com.mchange.v2.resourcepool.BasicResourcePool$5@f2ba36e (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#9), com.mchange.v2.resourcepool.BasicResourcePool$5@79f69289 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#5), com.mchange.v2.resourcepool.BasicResourcePool$5@2b0e9eed (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0); pendingTasks: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@4ce3efb0, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@88d3340, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@6e1fb322, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@6329b5a9, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@47559d1b, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@45bd7c33, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@1b251c0a, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@2153e272, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@a37bb76, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@50f44537, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@54ec4766, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@6443a518, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@150bfe15, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@46561f7e, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@402dad45, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@76caaded, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@7460df88, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@3f39569, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@6cd62285, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@5e748195, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@32e78da5, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@465bf, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@20b3de9b, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@dba2e3, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@53a2e585, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@6b8aa9a8, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@5c888bc0, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@88f19b6, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@6ae1001d, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@59cea6bc, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@e24aeb4, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@a49b2ad, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@6c718121, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@fd4d526, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@5df5b9e8, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@2f805e89, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@14be8cbc, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@6a099547, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@1b279eb4, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@46244959, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@784b9608, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@2a6724eb, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@59a8d60c, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@5b7cdbd0, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@6243639c, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@3640c92a, com.mchange.v2.c3p0.stmt.GooGooStatementCache$2@57570039] --



Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 11:13 pm 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
Blunted,

There is very much that's strange about this. In your testing, are you sure you are only setting up one Connection pool, with the config shown?

The first peculiar thing is that your settings show maxStatements and maxStatementsPerConnection as 0. But in the deadlock output (which shouldn't take an hour to spew!) shows a whole bunch of Statement pool related tasks waiting to be performed.

But those are not the tasks blocked. It is Connection.close() that is hanging -- the pool is trying to close() the physical Connections, and they are refusing to close. There is a known Oracle deadlock issue, that looks like this and is related to the Statement cache. But that should be fixed as of c3p0-0.9.0-pre6, which you are using, and you have Statement caching turned off, though a Statement cache appears...

I'll look into this. But please verify for me that... 1) c3p0-0.9.0-pre6 is in fact the library version being used (c3p0 now outputs a banner with its version and build, prior to any pool's config initialization dump); and 2) you don't have some other pool somewhere using a Statement pool (i.e. with maxStatements or maxStatementsPerConnection > 0.

Good luck, and thanks.

Steve (c3p0 guy)


Top
 Profile  
 
 Post subject: It appears that c3p0-0.9.0 doesn't cleanup thread pools
PostPosted: Mon Sep 19, 2005 3:38 pm 
Newbie

Joined: Wed Jun 29, 2005 6:41 am
Posts: 2
Location: California
My apologies in advance for any mistakes - this is my first post. I think I am experiencing the same problem.

I have a JUnit test that exercises a Postgres 8.0.2 database by iterating 25 times doing roughly similar tasks.

When I run this test using c3p0-0.8.5.1.jar, everything is well-behaved. c3p0 threads are created at the beginning of each of the 25 iterations, and shut down either at the end of each iteration or shortly after the next iteration begins. Using Process Explorer on WinXP to observe connections to Postgres while the test is running, I see that the number of connections never exceeds 20.

Then I swap in c3p0-0.9.0.jar. Nothing else has changed. When I run the same test, c3p0's threads hang around until the JVM shuts down. Although the threads my test spawns shut down, almost all 25 (one for each iteration) c3p0 TimerThreads and each of their 3 helper ThreadPoolAsynchronousRunner$PoolThreads hang around. That's about 100 c3p0 threads.

I am using:
Hibernate-Version: 2.1.7
Spring-Version: 1.1.3

My JUnit test runs the following pattern sequentially 25 times:
1) Spawn a thread. (3 other threads are launched to do other things.) Inside that thread do the following steps using raw sql in Hibernate (note that app is not launched & Spring is not used) :
2) Connect to Postgres DB and create tables
4) Connect to Postgres DB and rename tables
5) Connect to Postgres DB and insert rows
6) Connect to Postgres DB and rename tables
7) Connect to Postgres DB and drop tables
At the end of the test, launch the app using Spring. Shut down the app.
The test takes 30 minutes. During each iteration, my test launches 4 threads and c3p0 launches 4 threads.

My hibernate.properties contains:

Code:
hibernate.dialect=net.sf.hibernate.dialect.PostgreSQLDialect
hibernate.connection.driver_class=org.postgresql.Driver
hibernate.connection.username=postgres
hibernate.connection.password=postgres
hibernate.connection.url=jdbc:postgresql://localhost/Foo-Slot1
hibernate.connection.autocommit=false
#hibernate.default_schema=NOT-USED
hibernate.hsqldb.location=./.db/hsqldb/NIL
hibernate.jdbc.batch_size=0

hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N'
#hibernate.connection.pool_size=1
hibernate.cache.provider_class=net.sf.hibernate.cache.HashtableCacheProvider
hibernate.show_sql=false;

hibernate.connection.provider_class=net.sf.hibernate.connection.C3P0ConnectionProvider
hibernate.c3p0.max_size=100
hibernate.c3p0.min_size=1
hibernate.c3p0.timeout=5000
#The following line is ignored by Hibernate's Environment class:
hibernate.c3p0.max_statements_per_connection=100
hibernate.c3p0.max_statements=0
hibernate.c3p0.idle_test_period=300
#The following line is ignored by Hibernate's Environment class:
hibernate.c3p0.num_helper_threads=2
hibernate.c3p0.acquire_increment=1


My application context contains:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
   <!--Do NOT specify this bean. Specifying it causes Spring to not honor the hibernate.connection.provider_class property specified in the Hibernate properties section.
      See LocalSessionFactoryBean.afterPropertiesSet() {
         ...
         if (this.dataSource != null) {
            // set Spring-provided DataSource as Hibernate property
            config.setProperty(Environment.CONNECTION_PROVIDER, LocalDataSourceConnectionProvider.class.getName());//*** This causes a LocalDataSourceConnectionProvider

to be used instead of what you specified in the Hibernate property. ***
         }
         ...
      }
   <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName">
         <value>org.postgresql.Driver</value>
      </property>
      <property name="url">
         <value>jdbc:postgresql://localhost/Foo-Slot1</value>
      </property>
      <property name="username">
         <value>postgres</value>
      </property>
      <property name="password">
         <value>postgres</value>
      </property>
   </bean>
   -->
   <!-- Hibernate SessionFactory -->
   <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
      <!--Do NOT specify this bean. Specifying it causes Spring to not honor the hibernate.connection.provider_class property specified in the Hibernate properties section.
      <property name="dataSource">
         <ref local="dataSource"/>
      </property>
      -->
      <property name="mappingLocations">
         <list>
            <value>war.cache/WEB-INF/resource/Foo.hbm.xml</value>
         </list>
      </property>
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">net.sf.hibernate.dialect.PostgreSQLDialect</prop>
            <prop key="hibernate.query.substitutions">true 1, false 0, yes 'Y', no 'N'</prop>
            <!--prop key="hibernate.connection.pool_size">1</prop-->
            <prop key="hibernate.connection.autocommit">false</prop>
            <prop key="hibernate.cache.provider_class">net.sf.hibernate.cache.HashtableCacheProvider</prop>
            <prop key="hibernate.show_sql">false</prop>
            <!--<prop key="hibernate.default_schema">NOT-USED</prop>-->
            <!--prop key="hibernate.jdbc.batch_size">0</prop-->
            
            <!-- Connection pooling using c3p0 -->
            <prop key="hibernate.connection.provider_class">net.sf.hibernate.connection.C3P0ConnectionProvider</prop>
            <prop key="hibernate.c3p0.min_size">1</prop>
            <prop key="hibernate.c3p0.max_size">100</prop>
            <prop key="hibernate.c3p0.timeout">5000</prop> <!--in seconds-->
            <prop key="hibernate.c3p0.max_statements_per_connection">100</prop>
            <prop key="hibernate.c3p0.max_statements">0</prop>
            <prop key="hibernate.c3p0.idle_test_period">300</prop> <!--in seconds-->
            <prop key="hibernate.c3p0.num_helper_threads">2</prop> <!--Ignored by Hibernate's Environment class-->
            <prop key="hibernate.c3p0.acquire_increment">1</prop>
         </props>
      </property>
   </bean>
   <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
   <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
      <property name="sessionFactory">
         <ref local="sessionFactory"/>
      </property>
   </bean>
   <bean id="DomainObjectDAO" class="com.foo.framework.dist.storage.DomainObjectDAO">
      <property name="sessionFactory">
         <ref local="sessionFactory"/>
      </property>
   </bean>
</beans>


Top
 Profile  
 
 Post subject: Correction to applicationContext.xml
PostPosted: Mon Sep 19, 2005 6:47 pm 
Newbie

Joined: Wed Jun 29, 2005 6:41 am
Posts: 2
Location: California
My last post was missing the following hibernate properties:
Code:
            <prop key="hibernate.connection.driver_class">org.postgresql.Driver</prop>
            <prop key="hibernate.connection.url">jdbc:postgresql://localhost/Foo-Slot1</prop>
            <prop key="hibernate.connection.username">postgres</prop>
            <prop key="hibernate.connection.password">postgres</prop>


Top
 Profile  
 
 Post subject: Same Problem Here
PostPosted: Wed Sep 21, 2005 12:47 am 
Beginner
Beginner

Joined: Thu Jun 23, 2005 4:11 pm
Posts: 24
I'm also experiencing the same problem when switching from c3p0 0.8.5 to 0.9 using postgres and hibernate 3.0.5


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