From: Andrea Aime (JIRA) <jira@co...> - 2008-12-29 15:09:22
JDBCDelegatingTestSetup is leaking connections
Issue Type: Bug
Components: data jdbc-ng
Affects Versions: 2.5.2
Reporter: Andrea Aime
Assignee: Justin Deoliveira
Fix For: 2.5.3
JDBCDelegatingTestSetup is not delegating tearDown properly, and the base class is closing only BasicDataSource whilst it's creating a DBCPDataSource.
This leads to pool leaks, which make it impossible to run all the tests in a single shot, the database runs out of connections pretty quickly this way.
Also, they way things are setup each statement run in the setup creates a connection pool, as JDBCTestSupport.run() calls createDataSource, leaking the generated pool. I've made sure the pool is taken care of.
I've reworked things so that createDataSource can be called just once, and all access to it are performed thru getDataSource(), which uses a lazy creation idiom.
Double checked with the debugger, and made sure "only" two pools are created for each test run, one for checking the connection works in JDBCTestSupport.run(TestResult), and the other to actually run the test.
I also ahd run(TestResult) store also the postive connection test, worst case scenario the database goes down during the
test run, and that will most likely make one test fail anyways, so it's better to just store the result and accept the eventual N failures instead of the single one (the build is gone anyways).
Btw, to track down the presence of leaks and quantify them I used the server status tool provided by PgAdmin III, handy, it reports how many connections, by who, and doing what.
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira