Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0027878Openbravo ERPA. Platformpublic2014-10-15 14:412015-05-21 09:26
shuehner 
marvintm 
urgentmajorhave not tried
closedfixed 
5
 
3.0PR15Q1 
AugustoMauch
Core
No
0027878: Code in DalConnectionprovider relate to getTransactionConnection seems to leak db connections always
The DalConnectionProvider is a wrapper to implement the standard ConnectionProviderInterface but using dal to manage the connections.

In that interface are 3 related methods
1.) getTransactionConnection to get a new separate connection with auto commit disabled
2.) releaseCommitConnection. To commit & close a aconnection as obtained by 1.)
3.) releaseRollBackConnection. to rollback & close a connection as obtained by 1.)

Reading that code it seems that both 2+3 are implemented wrongly as they do not close the connection.

Problem was stopped while trying to debug the a very bad connection leak seen after this commit:
https://code.openbravo.com/erp/pmods-branches/org.openbravo.mobile.core.cds/rev/e0ff3b43bc13 [^]
-
Performance
related to defect 0027877 closed NaroaIriarte Possible connection leak in UsageAudit.java in error case 
related to design defect 0020580 closed mtaal DalBaseProcess always closes the connection 
related to defect 0033438 closed alostale DalConnectionProvider.getTransactionConnection does not obtain connection from common pool 
causes defect 00299023.0PR15Q3 closed alostale ProcessBundle.setCloseConnection(false) has no impact when using DalBaseProcess, the connection is always closed 
Issue History
2014-10-15 14:41shuehnerNew Issue
2014-10-15 14:41shuehnerAssigned To => AugustoMauch
2014-10-15 14:41shuehnerModules => Core
2014-10-15 14:41shuehnerTriggers an Emergency Pack => No
2014-10-15 14:41shuehnerRelationship addedrelated to 0027877
2014-10-28 16:06marvintmAssigned ToAugustoMauch => marvintm
2014-10-28 16:07marvintmReview Assigned To => alostale
2014-10-28 16:15hgbotCheckin
2014-10-28 16:15hgbotNote Added: 0071230
2014-10-28 16:15hgbotStatusnew => resolved
2014-10-28 16:15hgbotResolutionopen => fixed
2014-10-28 16:15hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/205fdc530e408b51a16a4d596c639339c607af95 [^]
2014-10-28 16:16marvintmNote Added: 0071231
2014-10-30 13:03AugustoMauchReview Assigned Toalostale => AugustoMauch
2014-10-30 13:03AugustoMauchNote Added: 0071268
2014-10-30 13:03AugustoMauchStatusresolved => closed
2014-10-30 13:03AugustoMauchFixed in Version => 3.0PR15Q1
2014-12-30 23:23hudsonbotCheckin
2014-12-30 23:23hudsonbotNote Added: 0072998
2015-05-15 13:11alostaleRelationship addedrelated to 0020580
2015-05-21 08:40alostaleRelationship addedcauses 0029902
2015-05-21 09:26alostaleTag Attached: Performance
2016-07-05 16:40alostaleRelationship addedrelated to 0033429
2016-07-06 10:14alostaleRelationship deletedrelated to 0033429
2016-07-06 10:15alostaleRelationship addedrelated to 0033438

Notes
(0071230)
hgbot   
2014-10-28 16:15   
Repository: erp/devel/pi
Changeset: 205fdc530e408b51a16a4d596c639339c607af95
Author: Antonio Moreno <antonio.moreno <at> openbravo.com>
Date: Tue Oct 28 16:14:40 2014 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/205fdc530e408b51a16a4d596c639339c607af95 [^]

Fixed issue 27878. Changed DalConnectionProvider so that it won't leak connections when using a transaction connection:
> - Now getTransactionConnection won't create a new StatelessSession every time it is called, because this created a new connection pool, and connections for this pool weren't reused. Instead, now the Hibernate ConnectionProvider in the DalSessionFactory is exposed, and used, to get a valid connection which belongs to the right pool.
- Additionally, now the connections are actually closed when the releaseCommitConnection or the releaseRollbackConnection methods are used.

---
M src/org/openbravo/dal/core/DalSessionFactory.java
M src/org/openbravo/service/db/DalConnectionProvider.java
---
(0071231)
marvintm   
2014-10-28 16:16   
After the changes, we have verified that:
- Connections are not leaked (an infinite loop doesn't reach the maximum number of connections in the database).
- The connection objects are different every time the getTransactionConnection method is called.
- If two transaction connections are created, and an operation is done in the first one, the second one doesn't see the results of it unless a commit is done in the first one.
(0071268)
AugustoMauch   
2014-10-30 13:03   
Code reviewed and verified in pi@38080222ded6.

I have tested this fix with an external connection pool [1] and it worked fine.

[1] http://wiki.openbravo.com/wiki/How_to_Use_an_External_Connection_Pool [^]
(0072998)
hudsonbot   
2014-12-30 23:23   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/6525fe229e06 [^]
Maturity status: Test