Openbravo Issue Tracking System - Openbravo ERP  | 
| View Issue Details | 
  | 
| ID | Project | Category | View Status | Date Submitted | Last Update | 
| 0027878 | Openbravo ERP | A. Platform | public | 2014-10-15 14:41 | 2015-05-21 09:26 | 
  | 
| Reporter | shuehner |   | 
| Assigned To | marvintm |   | 
| Priority | urgent | Severity | major | Reproducibility | have not tried | 
| Status | closed | Resolution | fixed |   | 
| Platform |  | OS | 5 | OS Version |  | 
| Product Version |  |   | 
| Target Version |  | Fixed in Version | 3.0PR15Q1 |   | 
| Merge Request Status |  | 
| Review Assigned To | AugustoMauch | 
| OBNetwork customer | No | 
| Web browser |  | 
| Modules | Core | 
| Support ticket |  | 
| Regression level |  | 
| Regression date |  | 
| Regression introduced in release |  | 
| Regression introduced by commit |  | 
| Triggers an Emergency Pack | No | 
  | 
| Summary | 0027878: Code in DalConnectionprovider relate to getTransactionConnection seems to leak db connections always | 
| Description | 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 [^] | 
| Steps To Reproduce | - | 
| Proposed Solution |  | 
| Additional Information |  | 
| Tags | Performance | 
| Relationships | | 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  | 0029902 | 3.0PR15Q3  | closed  | alostale  | ProcessBundle.setCloseConnection(false) has no impact when using DalBaseProcess, the connection is always closed  |  
  | 
| Attached Files |  | 
  | 
| Issue History | 
| Date Modified | Username | Field | Change | 
| 2014-10-15 14:41 | shuehner | New Issue |  | 
| 2014-10-15 14:41 | shuehner | Assigned To |  => AugustoMauch | 
| 2014-10-15 14:41 | shuehner | OBNetwork customer |  => No | 
| 2014-10-15 14:41 | shuehner | Modules |  => Core | 
| 2014-10-15 14:41 | shuehner | Triggers an Emergency Pack |  => No | 
| 2014-10-15 14:41 | shuehner | Relationship added | related to 0027877 | 
| 2014-10-28 16:06 | marvintm | Assigned To | AugustoMauch => marvintm | 
| 2014-10-28 16:07 | marvintm | Review Assigned To |  => alostale | 
| 2014-10-28 16:15 | hgbot | Checkin |  | 
| 2014-10-28 16:15 | hgbot | Note Added: 0071230 |  | 
| 2014-10-28 16:15 | hgbot | Status | new => resolved | 
| 2014-10-28 16:15 | hgbot | Resolution | open => fixed | 
| 2014-10-28 16:15 | hgbot | Fixed in SCM revision |  => http://code.openbravo.com/erp/devel/pi/rev/205fdc530e408b51a16a4d596c639339c607af95 [^] | 
| 2014-10-28 16:16 | marvintm | Note Added: 0071231 |  | 
| 2014-10-30 13:03 | AugustoMauch | Review Assigned To | alostale => AugustoMauch | 
| 2014-10-30 13:03 | AugustoMauch | Note Added: 0071268 |  | 
| 2014-10-30 13:03 | AugustoMauch | Status | resolved => closed | 
| 2014-10-30 13:03 | AugustoMauch | Fixed in Version |  => 3.0PR15Q1 | 
| 2014-12-30 23:23 | hudsonbot | Checkin |  | 
| 2014-12-30 23:23 | hudsonbot | Note Added: 0072998 |  | 
| 2015-05-15 13:11 | alostale | Relationship added | related to 0020580 | 
| 2015-05-21 08:40 | alostale | Relationship added | causes 0029902 | 
| 2015-05-21 09:26 | alostale | Tag Attached: Performance |  | 
| 2016-07-05 16:40 | alostale | Relationship added | related to 0033429 | 
| 2016-07-06 10:14 | alostale | Relationship deleted | related to 0033429 | 
| 2016-07-06 10:15 | alostale | Relationship added | related 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 
--- 
			 | 
		 
		 
	 | 
	
		 
	 | 
	| 
		
	 | 
	
		
		
			
				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.			 | 
		 
		 
	 | 
	
		 
	 | 
	| 
		
	 | 
	
		
	 | 
	
		 
	 | 
	| 
		
	 | 
	
		
	 |