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. DBCP-417.patch
        3 kB
        Phil Steitz
      2. test-dbcp2-BasicManagedDataSource.zip
        4 kB
        Balazs Zsoldos

        Activity

        Balazs Zsoldos created issue -
        Balazs Zsoldos made changes -
        Field Original Value New Value
        Description When a JTA Transaction is commited, the Managed connection is not available again. The pool is becomes exhausted.

        To reproduce:

        {code:java}
                    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.rollback();

                    // The managed datasource will block here as there is no available connection
                    userTransaction.begin();
                    connection = basicManagedDataSource.getConnection();
                    connection.close();
                    userTransaction.commit();
        {code}

        Set the priority to Blocker as BasicManagedDataSource cannot be used at all with the bug.
        When a JTA Transaction is commited, the Managed connection is not available again. The pool is becomes exhausted.

        To reproduce:

        {code:java}
        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.rollback();

        // The managed datasource will block here as there is no available connection
        userTransaction.begin();
        connection = basicManagedDataSource.getConnection();
        connection.close();
        userTransaction.commit();
        {code}

        Set the priority to Blocker as BasicManagedDataSource cannot be used at all with the bug.
        Balazs Zsoldos made changes -
        Description When a JTA Transaction is commited, the Managed connection is not available again. The pool is becomes exhausted.

        To reproduce:

        {code:java}
        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.rollback();

        // The managed datasource will block here as there is no available connection
        userTransaction.begin();
        connection = basicManagedDataSource.getConnection();
        connection.close();
        userTransaction.commit();
        {code}

        Set the priority to Blocker as BasicManagedDataSource cannot be used at all with the bug.
        When a JTA Transaction is commited, the Managed connection is not available again. The pool is becomes exhausted.

        To reproduce:

        {code:java}
        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();
        {code}

        Set the priority to Blocker as BasicManagedDataSource cannot be used at all with the bug.
        Balazs Zsoldos made changes -
        Description When a JTA Transaction is commited, the Managed connection is not available again. The pool is becomes exhausted.

        To reproduce:

        {code:java}
        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();
        {code}

        Set the priority to Blocker as BasicManagedDataSource cannot be used at all with the bug.
        When a JTA Transaction is commited, the Managed connection is not available again. The pool is becomes exhausted.

        To reproduce:

        {code:java}
        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();
        {code}

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

        Tested with Geronimo Transaction Manager and JOTM.
        Balazs Zsoldos made changes -
        Attachment test-dbcp2-BasicManagedDataSource.zip [ 12640534 ]
        Balazs Zsoldos made changes -
        Description When a JTA Transaction is commited, the Managed connection is not available again. The pool is becomes exhausted.

        To reproduce:

        {code:java}
        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();
        {code}

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

        Tested with Geronimo Transaction Manager and JOTM.
        When a JTA Transaction is commited, the Managed connection is not available again. The pool is becomes exhausted.

        To reproduce:

        {code:java}
        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();
        {code}

        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.
        Phil Steitz made changes -
        Attachment DBCP-417.patch [ 12640965 ]
        Phil Steitz made changes -
        Fix Version/s 2.0.1 [ 12326766 ]
        Phil Steitz made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Phil Steitz made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development