GeoTools
  1. GeoTools
  2. GEOT-2237

JDBCDelegatingTestSetup is leaking connections

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.2
    • Fix Version/s: 2.5.3
    • Component/s: jdbc
    • Labels:
      None

      Description

      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.

        Activity

        Hide
        Andrea Aime added a comment -
        Committed on 2.5.x and trunk. Please review/comment?
        Show
        Andrea Aime added a comment - Committed on 2.5.x and trunk. Please review/comment?
        Hide
        Justin Deoliveira added a comment -
        Patch looks good... did you run it on the various databases? Did it fix the problem you were having with mysql?
        Show
        Justin Deoliveira added a comment - Patch looks good... did you run it on the various databases? Did it fix the problem you were having with mysql?
        Hide
        Andrea Aime added a comment -
        Indeed it did, I can now run MySql tests fine.
        Show
        Andrea Aime added a comment - Indeed it did, I can now run MySql tests fine.
        Hide
        Andrea Aime added a comment -
        Fixed on 2.5.x and trunk
        Show
        Andrea Aime added a comment - Fixed on 2.5.x and trunk

          People

          • Assignee:
            Andrea Aime
            Reporter:
            Andrea Aime
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: