Commons Dbcp
  1. Commons Dbcp
  2. DBCP-298

CLONE -Connection socket hangs sporadically in DBCP 1.2.2 but not 1.2.1

    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:

      Fedora Core 3, MySQL 4.1.22. with the latest driver (5.07). Exceptions only occur in the "job processing" JVM, which sits idle for long periods of time and occasionally wakes up to interact with the database.

      Description

      I think I've traced an exception to DBCP's code.

      Communication with the database is hanging sporadically in a production environment. If I don't set the socketTimeout property on the underlying connection, it will hang forever. With the socketTimeout property, I get the following exception:

      -------
      com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

        • BEGIN NESTED EXCEPTION **

      java.net.SocketTimeoutException
      MESSAGE: Read timed out

      STACKTRACE:

      java.net.SocketTimeoutException: Read timed out
      at java.net.SocketInputStream.socketRead0(Native Method)
      at java.net.SocketInputStream.read(SocketInputStream.java:129)
      at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
      at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
      at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
      at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1994)
      at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2411)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2916)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:3250)
      at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1355)
      at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1270)
      at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228)
      ...
      -------

      It always happens in an infrequently used JVM (not an app server handling frequent connections). So it's likely the offending connection was asleep for a long time before the exception occurs.

      I've confirmed that this issue only occurs using 1.2.2 and not 1.2.1. I've been looking through the changelogs but can't find anything that would cause this behavior.

      Does somebody familiar with the codebase have any idea what change (1.2.1->1.2.2) could be causing this behavior?

      Thanks

        Issue Links

          Activity

          Hide
          Denson Kim added a comment -

          I am having the same problem of all tomcat process hung at getting a dabase connection:
          org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:96).

          I am using ms sql server 2005 and Microsoft jdbc driver.

          DBCP pool setting
          url=jdbc:sqlserver://mssqlsrv:1433;databaseName=cloud
          maxActive=20
          maxIdle=20
          testOnBorrow=true
          testOnReturn=false
          testWhileIdle=true

          1. 15 min
            timeBetweenEvictionRunsMillis=900000
          2. default value from DBCP 30min
            minEvictableIdleTimeMillis=1800000
            numTestsPerEvictionRun=1
            validationQuery=select 1

          dbcp version: 1.2.2
          common pool version:1.3

          Show
          Denson Kim added a comment - I am having the same problem of all tomcat process hung at getting a dabase connection: org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:96). I am using ms sql server 2005 and Microsoft jdbc driver. DBCP pool setting url=jdbc:sqlserver://mssqlsrv:1433;databaseName=cloud maxActive=20 maxIdle=20 testOnBorrow=true testOnReturn=false testWhileIdle=true 15 min timeBetweenEvictionRunsMillis=900000 default value from DBCP 30min minEvictableIdleTimeMillis=1800000 numTestsPerEvictionRun=1 validationQuery=select 1 dbcp version: 1.2.2 common pool version:1.3
          Hide
          Denson Kim added a comment -

          This is the same bug as evictor thread causing double deadlock. The solution is disable testWhileIdle.

          Show
          Denson Kim added a comment - This is the same bug as evictor thread causing double deadlock. The solution is disable testWhileIdle.

            People

            • Assignee:
              Unassigned
              Reporter:
              Denson Kim
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development