commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Thomas (JIRA)" <>
Subject [jira] [Resolved] (DBCP-355) DataSourceXAConnectionFactory does not store the XAConnection
Date Mon, 03 Feb 2014 13:54:09 GMT


Mark Thomas resolved DBCP-355.

       Resolution: Fixed
    Fix Version/s:     (was: 1.4.1)
                       (was: 1.3.1)

Thanks for the report and the fix. Sorry it has taken so long to address this.

I've fixed trunk for the 2.x series the 1.5.x branch. It will be included in the next release
of each.

I applied a slight variation of the proposed patch to take account of the naming conventions
for tests and supporting classes within DBCP and to resolve some IDE warnings.

If there are further 1.3.x and 1.4.x releases (currently being discussed on the dev mailing
list) my expectation is that they will be generated from the 1.5.x branch so will pick up
this fix too.

> DataSourceXAConnectionFactory does not store the XAConnection
> -------------------------------------------------------------
>                 Key: DBCP-355
>                 URL:
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 1.3, 1.4
>         Environment: MysqlXADataSource passed to BasicManagedDataSource
>            Reporter: Clement Pang
>             Fix For: 1.5.1, 2.0
>         Attachments: DBCP-355.diff
> 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.

This message was sent by Atlassian JIRA

View raw message