You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Florent Guillaume (Jira)" <ji...@apache.org> on 2020/05/13 18:08:00 UTC

[jira] [Updated] (DBCP-564) BasicManagedDataSource leaks connections opened after transaction is rollback-only

     [ https://issues.apache.org/jira/browse/DBCP-564?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Florent Guillaume updated DBCP-564:
-----------------------------------
    Description: 
In the following situation a connection will be leaked and never returned to the pool:
 * a {{BasicManagedDataSource}} is instantiated for a non-XA driver class name (but with a TransactionManager and a TransactionSynchronizationRegistry),
 * a transaction is started then switched to rollback-only,
 * a connection is acquired from the datasource,
 * the connection is closed,
 * the transaction is rolled back.

The leak happens because, even though there is code in {{TransactionContext.addTransactionContextListener}} to properly use the {{transactionSynchronizationRegistry}} to register the suitable {{Synchronization}} to do cleanup in {{afterCompletion}}, the {{transactionSynchronizationRegistry}} is actually {{null}} because of the way the {{LocalXAConnectionFactory}} was created in {{BasicManagedDataSource.createConnectionFactory}}.

PR: https://github.com/apache/commons-dbcp/pull/39

  was:
In the following situation a connection will be leaked and never returned to the pool:
 * a {{BasicManagedDataSource}} is instantiated for a non-XA driver class name (but with a TransactionManager and a TransactionSynchronizationRegistry),
 * a transaction is started then switched to rollback-only,
 * a connection is acquired from the datasource,
 * the connection is closed,
 * the transaction is rolled back.

The leak happens because, even though there is code in {{TransactionContext.addTransactionContextListener}} to properly use the {{transactionSynchronizationRegistry}} to register the suitable {{Synchronization}} to do cleanup in {{afterCompletion}}, the {{transactionSynchronizationRegistry}} is actually {{null}} because of the way the {{LocalXAConnectionFactory}} was created in {{BasicManagedDataSource.createConnectionFactory}}.

A PR with a test will be provided shortly.


> BasicManagedDataSource leaks connections opened after transaction is rollback-only
> ----------------------------------------------------------------------------------
>
>                 Key: DBCP-564
>                 URL: https://issues.apache.org/jira/browse/DBCP-564
>             Project: Commons DBCP
>          Issue Type: Bug
>    Affects Versions: 2.7.0
>            Reporter: Florent Guillaume
>            Priority: Minor
>
> In the following situation a connection will be leaked and never returned to the pool:
>  * a {{BasicManagedDataSource}} is instantiated for a non-XA driver class name (but with a TransactionManager and a TransactionSynchronizationRegistry),
>  * a transaction is started then switched to rollback-only,
>  * a connection is acquired from the datasource,
>  * the connection is closed,
>  * the transaction is rolled back.
> The leak happens because, even though there is code in {{TransactionContext.addTransactionContextListener}} to properly use the {{transactionSynchronizationRegistry}} to register the suitable {{Synchronization}} to do cleanup in {{afterCompletion}}, the {{transactionSynchronizationRegistry}} is actually {{null}} because of the way the {{LocalXAConnectionFactory}} was created in {{BasicManagedDataSource.createConnectionFactory}}.
> PR: https://github.com/apache/commons-dbcp/pull/39



--
This message was sent by Atlassian Jira
(v8.3.4#803005)