Uploaded image for project: 'Commons DBCP'
  1. Commons DBCP
  2. DBCP-272

Contention for DriverManager when initializing multiple datasources

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.2
    • Fix Version/s: 1.3
    • Labels:
      None
    • Environment:

      Java HotSpot(TM) 64-Bit Server VM (1.6.0-b105 mixed mode) on Linux

      Description

      This issue has been discussed in the commons user's mailing list between myself, Simon Kitching and Phil Steitz.

      In summary:

      I have a webapp deployed in tomcat containing 3 pooled datasources which are managed by Spring. The webapp starts up OK and is immediately hit by a load of a few hundred requests a second. It seems to handle a few hundred request and then just locks up entirely and stops responding entirely. Attached is a stack trace obtained by doing kill -3 when in this state. After discussion on the mailing list I changed the datasources to be non-lazy initialised in spring but the issue still occurs.

      Simon Kitching said:
      "The first thread is trying to initialise a postgresql driver and register it with DriverManager. The driver registration is being triggered from a static initialiser block on the postgresql driver class, so is executing from within the Class.forName method (and therefore the postgresql driver Class object is locked by this thread).

      The second thread is trying to initialise a mysql driver and register it with DriverManager. Again, the driver registration is being triggered from a static initialiser block on the mysql driver class, so the mysql driver Class object is locked by this thread).

      But in both cases, the DriverManager needs to be initialised before anything can be registered. The first thread appears to have run first, triggering the initialisation process, and the second thread is blocked waiting for initialisation of DriverManager to complete before it registers the mysql driver.

      <snip/>

      Possibly dbcp should call DriverManager.getDrivers() internally on startup to avoid this race... "

        Attachments

        1. catalina.out.stuck2
          918 kB
          Adrian Woodhead

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              adrianw Adrian Woodhead
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: