[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16737508#comment-16737508 ] Mark Thomas commented on DBCP-484: -- I don't think this meets the bar for a CVE. It can't be reliably triggered by a remote user. The bug appears to be rare enough that a malicious user isn't going to be able to exhaust server resources with this. Also, the abandoned connection clean-up releases the leaked resource. > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons DBCP > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Fix For: 2.4.0 > > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16737505#comment-16737505 ] Gary Gregory commented on DBCP-484: --- Hm... OK. Let's see if we get a volunteer ;-) > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons DBCP > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Fix For: 2.4.0 > > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16737468#comment-16737468 ] Gary Gregory commented on DBCP-484: --- I would not think this requires a CVE. What do others think? > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons DBCP > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Fix For: 2.4.0 > > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16737480#comment-16737480 ] David Dillard commented on DBCP-484: To be clear, the reason I asked about a CVE is that a resource leak can lead to a denial of service. > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons DBCP > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Fix For: 2.4.0 > > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16737421#comment-16737421 ] David Dillard commented on DBCP-484: I know this fix has been out a while, but any chance of getting a CVE for this? > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons DBCP > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Fix For: 2.4.0 > > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16482296#comment-16482296 ] Mark Thomas commented on DBCP-484: -- A reliable unit test for a race condition is always going to be tricky. The patch looks good to me. I've commented on the PR. > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons DBCP > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16482220#comment-16482220 ] Zheng Feng commented on DBCP-484: - Also we have worked with more tests by using the Narayana and the DBCP2 and will raise the PR for DBCP-491 after we release 5.8.2.Final of Narayana > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons DBCP > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16482218#comment-16482218 ] Zheng Feng commented on DBCP-484: - The Narayana dependency is in the dbcp-test. I have verified the TestLeak.java works fine with the fix of JBTM-3021. And we will release the Narayana 5.8.2.Final soon I hope in this week. So I would suggest to close this issue as "Migrated to other ITS" and mark with JBTM-3021 > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons DBCP > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16481976#comment-16481976 ] Gary Gregory commented on DBCP-484: --- Hm... where are we on this? > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons DBCP > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16476664#comment-16476664 ] Zheng Feng commented on DBCP-484: - There could be an issue with the Narayana related to the afterCompletion and I think we have fixed in [JBTM-3021|https://issues.jboss.org/browse/JBTM-3021] which should be include in the Narayan 5.8.2.Final > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons DBCP > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16435211#comment-16435211 ] Martyn Taylor commented on DBCP-484: It's a question of whether or not the LGPL licensed dependency is distributed as part of the Apache project. Build time dependencies are OK[1]. The licensing documentation is not explicit about test dependencies. In ActiveMQ Artemis we don't distribute tests and don't redistribute Byteman. As a precautionary measure, we disable by default tests that pull down libraries with prohibited licenses. TBH I don't believe this is necessary. If you're still unsure I would fire an email off to Apache security to verify. 1. [https://www.apache.org/legal/resolved.html#prohibited] > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16434549#comment-16434549 ] Gary Gregory commented on DBCP-484: --- Nice find in Apache MQ [~zhfeng]! I'm curious if anyone in our community has any thoughts here? Because Apache MQ uses it in their tests does not make it right, but I would hope that they've validated this dependency... Gary > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16431873#comment-16431873 ] Zheng Feng commented on DBCP-484: - [~garydgregory], it looks like that the ActiveMQ already uses the byteman in their tests[1]. So I think it could be OK to just include the byteman as the testsing purpose. [1] https://github.com/apache/activemq-artemis/blob/master/tests/extra-tests/pom.xml#L46 > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16421043#comment-16421043 ] Gary Gregory commented on DBCP-484: --- Good question. IANAL, but it looks like a no: [https://www.apache.org/legal/resolved.html:] {quote} GNU LGPLThe LGPL is ineligible primarily due to the restrictions it places on larger works, violating the third license criterion. {quote} More: - [https://www.apache.org/licenses/] - https://www.apache.org/foundation/license-faq.html > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16420264#comment-16420264 ] Zheng Feng commented on DBCP-484: - [~garydgregory], I think we can add a test to simulate the race condition with the [Byteman|https://http//byteman.jboss.org/] tool which is licensed by the LGPL. I'm not sure this could be used in the apache project ? > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16419046#comment-16419046 ] Gary Gregory commented on DBCP-484: --- [~zhfeng]: Thank you for your PR! Do you think you could augment your PR with a unit test that fails unless the {{main}} portion of the patch is applied? Thank you, Gary > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16416993#comment-16416993 ] Zheng Feng commented on DBCP-484: - I just opened https://github.com/apache/commons-dbcp/pull/10 for fixing this issue. > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16416323#comment-16416323 ] Gary Gregory commented on DBCP-484: --- I attached the zip file from https://www.dropbox.com/s/g0oiz2wizmedeqs/dbcp-test.zip?dl=0 to this ticket. > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > Attachments: dbcp-test.zip > > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16410711#comment-16410711 ] Zheng Feng commented on DBCP-484: - Hi, I think there might be a race condition when closing the ManagedConnection There are two methods which could call connection.close() and the one is in [ManagedConnection.close()|https://github.com/apache/commons-dbcp/blob/master/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java#L160] and the other is [ManagedConncetion.transactionComplete()|https://github.com/apache/commons-dbcp/blob/master/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java#L188] which is used in calling back when the transaction is completed. {code} public void close() throws SQLException { if (!isClosedInternal()) { try { // Don't actually close the connection if in a transaction. The // connection will be closed by the transactionComplete method. if (transactionContext == null) { super.close(); } } finally { setClosedInternal(true); } } } {code} The thread of close() could be switched after check (transactionContext == null) and before the setCloseInternal(true). So it thinks it is still in a transaction but dose not set the _closed. {code} protected void transactionComplete() { transactionContext = null; // If we were using a shared connection, clear the reference now that // the transaction has completed if (isSharedConnection) { setDelegate(null); isSharedConnection = false; } // If this connection was closed during the transaction and there is // still a delegate present close it final Connection delegate = getDelegateInternal(); if (isClosedInternal() && delegate != null) { try { setDelegate(null); if (!delegate.isClosed()) { delegate.close(); } } catch (final SQLException ignored) { // Not a whole lot we can do here as connection is closed // and this is a transaction callback so there is no // way to report the error. } } } {code} The thread of transationComplete() should check isClosedInternal() which is still false. So it will not close the connection. And the connection.close() is missed both in close() and transactionComplete(). I think it could be one cause of the connection leaking. > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16390640#comment-16390640 ] Zheng Feng commented on DBCP-484: - [~ejsfreitas], I'm from the narayana team and I'm looking into this test. can you provide the command to run the TestLeak ? I just use "mvn clean test" but it looks like can not run the test. Thanks, Amos > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16369153#comment-16369153 ] Emanuel Freitas commented on DBCP-484: -- Hello [~garydgregory], did you had the chance to see the test? Kind regards, Emanuel > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16346724#comment-16346724 ] Emanuel Freitas commented on DBCP-484: -- Hello, For some reason (JIRA could not attach the file as there was a missing token. Please try attaching the file again.) i'm not able to atach the files. Where is a link to dropbox: [https://www.dropbox.com/s/g0oiz2wizmedeqs/dbcp-test.zip?dl=0] If you run the TeskLeak you can see that if you increase the number of threads (nthreads) you start getting some leaks. On our project I was able to fix the issue with the code that I posted above, but for this test the problem is something else. For this tests I was using a PostgreSQL database. Thanks for your help. Kind regards, Emanuel > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16343981#comment-16343981 ] Gary Gregory commented on DBCP-484: --- OK, let us know when you get that unit test working/failing. Above, I meant Apache Commons POOL 2.5.0 coupled with Apache Commons DBCP 2.2.0. > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16343701#comment-16343701 ] Emanuel Freitas commented on DBCP-484: -- Hello [~garydgregory], thanks for your fast answer. As you asked I'm working on a small test case but without any success yet. Yes, I'm also using Apache Commons 2.5.0 Kind regards, Emanuel > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DBCP-484) Connection leak during XATransaction in high load
[ https://issues.apache.org/jira/browse/DBCP-484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16339444#comment-16339444 ] Gary Gregory commented on DBCP-484: --- Hello and thank you for your report. Can you make sure you are also bringing in Apache Commons 2.5.0? Can you provide a small test case program that reproduces the problem? Preferably in the for a JUnit test case? Thank you! Gary > Connection leak during XATransaction in high load > - > > Key: DBCP-484 > URL: https://issues.apache.org/jira/browse/DBCP-484 > Project: Commons Dbcp > Issue Type: Bug >Affects Versions: 2.2.0 >Reporter: Emanuel Freitas >Priority: Major > > We're experiencing a connection leak in a distributed transaction when the > system is under heavy load. We're using commons-dbcp (latest version) + > eclipselink and narayana to perform transaction coordination. > From time to time we can see a stacktrace reporting an abandoned connection. > We are trying to figure out what's the root cause and we think that might be > some issue in the commons dbcp (not sure) . More specifically, this parte of > the code: > ManagedConnection#updateTransactionStatus > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > // transaction should have been cleared up by TransactionContextListener, > but in > // rare cases another lister could have registered which uses the > connection before > // our listener is called. In that rare case, trigger the transaction > complete call now > transactionComplete(); > }{code} > > If the transactionContext is different than null but the state is not > "active" (ex: STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, etc) it executes the > transactionComplete mothod that clears the reference to a shared connection > and after that the connection is never closed (returned to the pool). > > If we move the transactionComplete(); to an else,(see below), the connection > leak does not happen. > {code:java} > if (transactionContext != null) { > if (transactionContext.isActive()) { > if (transactionContext != > transactionRegistry.getActiveTransactionContext()) { > throw new SQLException("Connection can not be used while enlisted > in another transaction"); > } > return; > } > } else { > transactionComplete(); > }{code} > > After this the dbcp unit tests still pass but I'm not sure about this > changes. Can you please check? > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005)