tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 50805] New: Leak & Performance issue of getConnectionAsync()
Date Fri, 18 Feb 2011 04:11:44 GMT

           Summary: Leak & Performance issue of getConnectionAsync()
           Product: Tomcat Modules
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: jdbc-pool

Created an attachment (id=26677)
 --> (
patch for ConnectionPool

Leak and performance issue occurs when using getConnectionAsync().

getConnectionAsync() calls borrowConnection(int, String, String), and add
PooledConnection to the busy queue.
future.get() also calls borrowConnection(long, PooledConnection, String,
String), and same PooledConnection is added to the busy queue again.
The first connection is removed from the busy queue when returnConnection() is
called, but the second one remains as garbage.
The busy queue overflows at once because of these garbage connection.
Int this time, ConnectionPool.size is smaller than busy queue size. And new
real connection is created when getConnectionAsync() is called.
And, when the busy queue overflows, the connection is released in
ConnectionPool.returnConnection(). This causes the problem of the performance. 

Furthermore, in most case the following codes are not executed, because
borrowConnection(int, String, String) is not returned null except as validation

    149         if (idle instanceof FairBlockingQueue<?>) {
    150             Future<PooledConnection> pcf =
    151             return new ConnectionFuture(pcf);
    152         } else if (idle instanceof MultiLockFairBlockingQueue<?>) {
    153                 Future<PooledConnection> pcf =
    154                 return new ConnectionFuture(pcf);
    155         } else {
    156             throw new SQLException("Connection pool is misconfigured,
doesn't support async retrieval. Set the 'fair' property to 'true'");
    157         }

Based on above, I improved the getConnectionAsync().

Best regards.

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message