commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keijo Lehto <keij...@gmail.com>
Subject [dbcp] Database connections disappear from the pool
Date Fri, 28 Oct 2005 09:05:11 GMT
Hello,

we're currently having problems with DBCP connection pooling on a
server application we've developed. Our app runs perfectly for hours
serving tens of thousands of requests, but suddenly, it just freezes
while trying to get a database connection from the DBCP pool.

We've added more verbose logging to the application and discovered
that just before hanging, the pool is working fine (1 active, 4 idle
conns) but then suddenly, after returning a connection to the pool as
usual we find out that the next time we try to borrow a connection,
there are 0 active and 0 idle connections in the pool.

At that point, the thread just waits indefinitely (well, at least for
hours) for the return from the call to
DriverManager.getConnection("jdbc:apache:commons:dbcp:/poolname"). No
Exceptions are thrown, no timeouts, no nothing.

The server application is responsive, though, and it accepts new
connections on new threads, which will also hang. However, all these
consequent requests hang already while trying to print the pool
statistics from corresponding ObjectPool so they don't even get to the
point of calling the getConnection(). We do, however, get the
ObjectPool from DriverManager:

PoolingDriver driver = (PoolingDriver)
DriverManager.getDriver("jdbc:apache:commons:dbcp:");
ObjectPool connectionPool = driver.getConnectionPool("/poolname");

Based on our analysis, we could not see any correlation between the
number of served requests and the problem. We also haven't been able
to reproduce the problem in our testing environments, it only occurs
in the production. So far, we haven't been able to see anything
special in e.g. the rate of requests before the hanging.

I haven't been able to find any previous conversation on similar
problems and we feel that the problem could be related to internals of
either DBCP or Jakarta Pool. Any ideas, references, comments?

Best regards,
- keke

PS. here are some details on our current configuration.
The database in use: Oracle 9.2.0
OS: SunOS 5.8
Our current jocl configuration is as follows:
<object class="org.apache.commons.dbcp.PoolableConnectionFactory"
xmlns="http://apache.org/xml/xmlns/jakarta/commons/jocl">
  <!-- the first argument is the ConnectionFactory -->
  <object class="org.apache.commons.dbcp.DriverManagerConnectionFactory">
     <string value="jdbc:oracle:thin:xxx/xxx@xxx:xxx:xxxx"/>
     <object class="java.util.Properties" null="true"/>
  </object>

  <!-- the next argument is the ObjectPool -->
  <object class="org.apache.commons.pool.impl.GenericObjectPool">
     <object class="org.apache.commons.pool.PoolableObjectFactory"
null="true"/>
     <int value="50"/> <!-- max active -->
     <byte value="0"/> <!-- when exhausted action, 0 = fail, 1 =
block, 2 = grow -->
     <long value="2000"/> <!-- max wait -->
     <int value="20"/> <!-- max idle -->
     <int value="5"/> <!-- min idle -->
     <boolean value="false"/> <!-- test on borrow -->
     <boolean value="false"/> <!-- test on return -->
     <long value="10000"/> <!-- time between eviction runs -->
     <int value="5"/> <!-- number of connections to test per eviction run -->
     <long value="5000"/> <!-- min evictable idle time -->
     <boolean value="true"/> <!-- test while idle -->
  </object>

  <!-- the next argument is the KeyedObjectPoolFactory -->
  <object class="org.apache.commons.pool.impl.StackKeyedObjectPoolFactory">
     <int value="5"/> <!-- max idle -->
  </object>

  <string value="SELECT COUNT(*) FROM DUAL"/> <!-- validation query -->
  <boolean value="false"/> <!-- default read only -->
  <boolean value="true"/> <!-- default auto commit -->
</object>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message