Commons Dbcp
  1. Commons Dbcp
  2. DBCP-205

Intermittently getting "Could not retrieve connection info from pool" when under load

    Details

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

      JRE 1.4.2_03, commons_dbcp20061206, commons-pool-1.2, Microsoft SQL Server 2005 JDBC Driver (sqljdbc_1.0.809.102)

      Description

      I have a Tomcat servlet that uses a connection pool with the following settings:

      MaxActive=30
      MaxIdle=3
      MaxWait=50000 milliseconds
      IdleTimeOut=3600 seconds
      LoginTimeOut=100 seconds
      TimeBetweenEvictionRunsMills=-1

      Under load, I get the following exception:

      org.apache.commons.dbcp.SQLNestedException: Could not retrieve connection info from pool
      at org.apache.commons.dbcp.datasources.SharedPoolDataSource.getPooledConnectionAndInfo(SharedPoolDataSource.java:171)
      at org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(InstanceKeyDataSource.java:662)
      at org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(InstanceKeyDataSource.java:646)

      Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.BindException: Address already in use: connect
      at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
      at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS.getPooledConnection(DriverAdapterCPDS.java:177)
      at org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS.getPooledConnection(DriverAdapterCPDS.java:132)
      at org.apache.commons.dbcp.datasources.KeyedCPDSConnectionFactory.makeObject(KeyedCPDSConnectionFactory.java:158)
      at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:747)
      at org.apache.commons.dbcp.datasources.SharedPoolDataSource.getPooledConnectionAndInfo(SharedPoolDataSource.java:167)

        Issue Links

          Activity

          Hide
          Phil Steitz added a comment -

          The lock contention issue here should be resolved by the changes in pool 1.4. I don't see a remaining dbcp bug here.

          Show
          Phil Steitz added a comment - The lock contention issue here should be resolved by the changes in pool 1.4. I don't see a remaining dbcp bug here.
          Hide
          Henri Yandell added a comment -

          Agreed - seems to be that the JDBC driver/db just doesn't like the amount of activity.

          Not that I grok how the driver could be running out of client side ports to connect from; there're tons of those aren't there?

          Might be a SQL Server driver specific bit I guess if it's trying to define the actual port to connect from and it's getting screwed up for some reason.

          Show
          Henri Yandell added a comment - Agreed - seems to be that the JDBC driver/db just doesn't like the amount of activity. Not that I grok how the driver could be running out of client side ports to connect from; there're tons of those aren't there? Might be a SQL Server driver specific bit I guess if it's trying to define the actual port to connect from and it's getting screwed up for some reason.
          Hide
          Phil Steitz added a comment -

          Moving this to 1.3 fix version - though I don't know if this is something that we can fix in dbcp. It does not look like the actual bug report ed is DBCP-related. More likely this is the result of heavy socket open/close activity when a loaded server is trying to keep maxIdle very low. What is really being requested here is an adaptive / more advanced pool management capability - create headroom during loaded periods, but then quiesce when load abates.

          Show
          Phil Steitz added a comment - Moving this to 1.3 fix version - though I don't know if this is something that we can fix in dbcp. It does not look like the actual bug report ed is DBCP-related. More likely this is the result of heavy socket open/close activity when a loaded server is trying to keep maxIdle very low. What is really being requested here is an adaptive / more advanced pool management capability - create headroom during loaded periods, but then quiesce when load abates.
          Hide
          Rida Ligurs added a comment -

          Hi Phil,

          Thanks for your response. I tried your suggestion of increasing maxIdle
          to 10 and it worked. I really didn't want to have 10 connections
          sitting idle. Is this a bug? In my case, under regular load it only
          gets to a maximum of 4 or 5 active connections. For those rare
          instances where there are significantly more active connections, I would
          want them to be release as soon as they are no longer needed.

          Rida

          Show
          Rida Ligurs added a comment - Hi Phil, Thanks for your response. I tried your suggestion of increasing maxIdle to 10 and it worked. I really didn't want to have 10 connections sitting idle. Is this a bug? In my case, under regular load it only gets to a maximum of 4 or 5 active connections. For those rare instances where there are significantly more active connections, I would want them to be release as soon as they are no longer needed. Rida
          Hide
          Phil Steitz added a comment -

          Do you see anything in the Windows event log on the SQL Server box? Is Tomcat running on the same box? That error could happen if the OS is unable to assign a (client) port for a new connection. Your config should be limiting the number of db connections from the servlet. Are there other clients hitting the SQL server concurrently? If not, can you verify that there are no more than 30 open at a given time?

          This is not likely related to your problem, but if you are using a recent dbcp nightly, you should be using pool 1.3 (release version) rather than 1.2.

          If your load is variable, the low maxIdle setting above could be causing a lot of connection churn which might be part of the problem. Try increasing that setting to 8 or 10.

          Show
          Phil Steitz added a comment - Do you see anything in the Windows event log on the SQL Server box? Is Tomcat running on the same box? That error could happen if the OS is unable to assign a (client) port for a new connection. Your config should be limiting the number of db connections from the servlet. Are there other clients hitting the SQL server concurrently? If not, can you verify that there are no more than 30 open at a given time? This is not likely related to your problem, but if you are using a recent dbcp nightly, you should be using pool 1.3 (release version) rather than 1.2. If your load is variable, the low maxIdle setting above could be causing a lot of connection churn which might be part of the problem. Try increasing that setting to 8 or 10.

            People

            • Assignee:
              Unassigned
              Reporter:
              Rida Ligurs
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development