Commons Dbcp
  1. Commons Dbcp
  2. DBCP-229

Track callers of active connections for debugging

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Labels:
      None

      Description

      Lately we got the following exception
      org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted
      at
      org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:103)
      at
      org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)

      The reason for that was that some piece of code opened a connection, but never closed it. Tracking the active connections (and the callers of the getConnection method) would it make it easier to find such erroneous code.
      One possible approach would be to add the connection returned by BasicDataSource.getConnection together with the stacktrace in a Map holding all active connections. And removing the connection from the map during PoolableDataSource.close().

        Activity

        Hide
        Henri Yandell added a comment -

        This would be a cool debug mode to have, though I wonder if it would get used more than the alternatives of logging or a profiling/debugging tool.

        Have we considered a JMX wrapper for DBCP? That would be one way to access such debug data.

        Show
        Henri Yandell added a comment - This would be a cool debug mode to have, though I wonder if it would get used more than the alternatives of logging or a profiling/debugging tool. Have we considered a JMX wrapper for DBCP? That would be one way to access such debug data.
        Hide
        Mark Thomas added a comment -

        Abandoned object logging will help for DBCP < 2.0

        For DBCP 2.0 the call stacks to getConnection() will be available via JMX.

        Show
        Mark Thomas added a comment - Abandoned object logging will help for DBCP < 2.0 For DBCP 2.0 the call stacks to getConnection() will be available via JMX.

          People

          • Assignee:
            Unassigned
            Reporter:
            Armin Häberling
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development