Uploaded image for project: 'Commons DBCP'
  1. Commons DBCP
  2. DBCP-355

DataSourceXAConnectionFactory does not store the XAConnection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3, 1.4
    • 1.5.1, 2.0
    • None
    • MysqlXADataSource passed to BasicManagedDataSource

    Description

      We have been diagnosing a leak with DBCP and XA mySQL and discovered that the mySQL driver expects close() to be invoked on the XAConnection obtained from xaDataSource.getXAConnection() instead of the java.sql.Connection returned by xaConnection.getConnection();

      The following code snippet in DataSourceXAConnectionFactory illustrates how the XAConnection is lost:

      public Connection createConnection() throws SQLException {
      // create a new XAConection
      XAConnection xaConnection;
      if (username == null)

      { xaConnection = xaDataSource.getXAConnection(); }

      else

      { xaConnection = xaDataSource.getXAConnection(username, password); }

      // get the real connection and XAResource from the connection
      Connection connection = xaConnection.getConnection();
      XAResource xaResource = xaConnection.getXAResource();

      // register the xa resource for the connection
      transactionRegistry.registerConnection(connection, xaResource);

      return connection;
      }

      In the code snippet above, the XAConnection is basically discarded after using it to obtain the java.sql.Connection and XAResource. It would be ideal if it actually associates the XAConnection in the transactionRegistry as well so that when PooledManagedConnection handles reallyClose(), it can also invoke close() on the XAConnection by interrogating the TransactionRegistry for the actual XAConnection to close.

      This may be something that's mySQL specific.

      Attachments

        1. DBCP-355.diff
          14 kB
          Florent Guillaume

        Issue Links

          Activity

            People

              Unassigned Unassigned
              panghy Clement Pang
              Votes:
              4 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: