Commons Dbcp
  1. Commons Dbcp
  2. DBCP-417

BasicManagedDataSource does not free connection after transaction is commited

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.1
    • Labels:
      None
    • Environment:

      Geronimo TM and JOTM, H2Database JDBC Driver

      Description

      When a JTA Transaction is commited, the Managed connection is not available again. The pool is becomes exhausted.

      To reproduce:

      Jotm jotm = new Jotm(true, false);
      JdbcDataSource h2DataSource = new JdbcDataSource();
      h2DataSource.setUrl("jdbc:h2:mem:test_mem");
      BasicManagedDataSource basicManagedDataSource = new BasicManagedDataSource();
      basicManagedDataSource.setTransactionManager(jotm.getTransactionManager());
      basicManagedDataSource.setXaDataSourceInstance(h2DataSource);
      basicManagedDataSource.setMaxTotal(2);
      basicManagedDataSource.setMaxIdle(2);
      
      UserTransaction userTransaction = jotm.getUserTransaction();
      userTransaction.begin();
      Connection connection = basicManagedDataSource.getConnection();
      connection.close();
      userTransaction.commit();
      
      userTransaction.begin();
      connection = basicManagedDataSource.getConnection();
      connection.close();
      userTransaction.commit();
      
      // The managed datasource will block here as there is no available connection
      userTransaction.begin();
      connection = basicManagedDataSource.getConnection();
      connection.close();
      userTransaction.commit();
      

      Set the priority to Blocker as BasicManagedDataSource cannot be used at all with the bug.

      Tested with Geronimo Transaction Manager and JOTM.

      This worked well with version 1.4.

      1. test-dbcp2-BasicManagedDataSource.zip
        4 kB
        Balazs Zsoldos
      2. DBCP-417.patch
        3 kB
        Phil Steitz

        Activity

        Hide
        Phil Steitz added a comment -

        Patch committed in r1592132

        Show
        Phil Steitz added a comment - Patch committed in r1592132
        Hide
        Phil Steitz added a comment -

        Test case and proposed patch. I am not sure I understand fully the intent of the r1547553 changes, so will wait for review to commit.

        Show
        Phil Steitz added a comment - Test case and proposed patch. I am not sure I understand fully the intent of the r1547553 changes, so will wait for review to commit.
        Hide
        Phil Steitz added a comment -

        Thanks for reporting this. It looks to me like this was caused by the refactoring changes in r1547553.

        Show
        Phil Steitz added a comment - Thanks for reporting this. It looks to me like this was caused by the refactoring changes in r1547553.
        Hide
        Balazs Zsoldos added a comment -

        Attaching a test project that reproduces the problem. See the Unit test under src/test/java.

        Show
        Balazs Zsoldos added a comment - Attaching a test project that reproduces the problem. See the Unit test under src/test/java.

          People

          • Assignee:
            Unassigned
            Reporter:
            Balazs Zsoldos
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development