Uploaded image for project: 'iBatis for Java [READ ONLY]'
  1. iBatis for Java [READ ONLY]
  2. IBATIS-780

PooledDataSource does not test connection when poolPingConnectionsNotUsedFor = 0 (the default)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0 GA Candidate
    • 3.0.1 GA
    • Core
    • None

    Description

      When poolPingConnectionsNotUsedFor = 0 (the default), the connection is not tested (contrary to documentation.)

      Enable DEBUG logging, and observe connection is not tested when poolPingConnectionsNotUsedFor = 0:

      [Dispatcher-0] DEBUG org.apache.ibatis.datasource.pooled.PooledDataSource - Created connection 23735419.
      [Dispatcher-0] DEBUG java.sql.Connection - ooo Connection Opened
      [Dispatcher-0] DEBUG java.sql.PreparedStatement - ==> Executing: SELECT ... elided ...
      [Dispatcher-0] DEBUG java.sql.ResultSet - <== ... elided ...
      [Dispatcher-0] DEBUG java.sql.ResultSet - <== ... elided ...
      [Dispatcher-0] DEBUG java.sql.Connection - xxx Connection Closed

      Change poolPingConnectionsNotUsedFor = 1, and repeat. Observe connection is tested:

      [Dispatcher-0] DEBUG org.apache.ibatis.datasource.pooled.PooledDataSource - Created connection 15469440.
      [Dispatcher-0] DEBUG org.apache.ibatis.datasource.pooled.PooledDataSource - Testing connection 15469440 ...
      [Dispatcher-0] DEBUG org.apache.ibatis.datasource.pooled.PooledDataSource - Connection 15469440 is GOOD!
      [Dispatcher-0] DEBUG java.sql.Connection - ooo Connection Opened
      [Dispatcher-0] DEBUG java.sql.PreparedStatement - ==> Executing: SELECT ... elided ...
      [Dispatcher-0] DEBUG java.sql.ResultSet - <== ... elided ...
      [Dispatcher-0] DEBUG java.sql.ResultSet - <== ... elided ...
      [Dispatcher-0] DEBUG java.sql.Connection - xxx Connection Closed
      [Dispatcher-0] DEBUG org.apache.ibatis.datasource.pooled.PooledDataSource - Testing connection 15469440 ...
      [Dispatcher-0] DEBUG org.apache.ibatis.datasource.pooled.PooledDataSource - Connection 15469440 is GOOD!
      [Dispatcher-0] DEBUG org.apache.ibatis.datasource.pooled.PooledDataSource - Returned connection 15469440 to pool.

      Verified issue exists w/ current trunk version (r936290).

      Proposed patch:

      [mstahl@mstahl-dev2 pooled]$ diff -u PooledDataSource.java PooledDataSource.java.fixed
      — PooledDataSource.java 2010-04-21 13:14:16.000000000 +0000
      +++ PooledDataSource.java.fixed 2010-04-21 13:15:41.000000000 +0000
      @@ -438,7 +438,7 @@

      if (result) {
      if (poolPingEnabled) {

      • if (poolPingConnectionsNotUsedFor > 0 && conn.getTimeElapsedSinceLastUse() > poolPingConnectionsNotUsedFor) {
        + if (poolPingConnectionsNotUsedFor >= 0 && conn.getTimeElapsedSinceLastUse() > poolPingConnectionsNotUsedFor) {
        try {
        if (log.isDebugEnabled()) {
        log.debug("Testing connection " + conn.getRealHashCode() + " ...");

      Attachments

        Activity

          People

            cbegin Clinton Begin
            mstahl Matthew Stahl
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: