https://issues.apache.org/bugzilla/show_bug.cgi?id=50805
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 AssignedTo: dev@tomcat.apache.org ReportedBy: mashm...@gmail.com Created an attachment (id=26677) --> (https://issues.apache.org/bugzilla/attachment.cgi?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 failed. 149 if (idle instanceof FairBlockingQueue<?>) { 150 Future<PooledConnection> pcf = ((FairBlockingQueue<PooledConnection>)idle).pollAsync(); 151 return new ConnectionFuture(pcf); 152 } else if (idle instanceof MultiLockFairBlockingQueue<?>) { 153 Future<PooledConnection> pcf = ((MultiLockFairBlockingQueue<PooledConnection>)idle).pollAsync(); 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: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org