Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0023882Openbravo ERPA. Platformpublic2013-05-22 11:432017-03-15 20:20
alostale 
alostale 
highminoralways
closedfixed 
5
 
3.0PR17Q2 
caristu
Core
No
0023882: 2 dangling DB connections after Tomcat start
During the Tomcat startup process 2 connections are created in database which are never released to the pool, so they are kept forever consuming some resources.
* Using pg9 (just to better monitor)
* Ensure there are no scheduled background processes
* Close all browsers and restart Tomcat
* Check connections (select * from pg_stat_activity): 2 connections are opened
* Operate the application for a while. Check the 2 connections that were present at the beginning are still there, the last query executed for each of them and their state change time have not been modified, this means they are not reused.



select state_change, substr(query,0,100) from pg_stat_activity where state = 'idle' order by state_change;
         state_change | substr
-------------------------------+-----------------------------------------------------------------------------------------------------
 2015-10-28 14:52:25.521975+00 | SET extra_float_digits = 3
 2015-10-28 14:52:40.112256+00 | UPDATE AD_SYSTEM_INFO SET SYSTEM_STATUS = $1
 2015-11-11 10:07:02.736565+00 | UPDATE AD_Session SET SESSION_ACTIVE = 'N' WHERE AD_Session.AD_Session_ID =
 2015-11-11 10:09:10.412948+00 | SELECT AD_AVAILABLE_UPDATE_ID, ISACTIVE, COMPONENT, OPTION_NAME, OPTION_VERSION, DESCRIPTION, U
 2015-11-11 10:10:46.469835+00 | COMMIT
(5 rows)
Performance
duplicate of defect 0036274 closed alostale abandoned connection in SessionListener 
related to defect 00238183.0MP24 closed alostale Background scheduler takes 10 connections to database and never releases those 
related to defect 0035356 closed caristu print & attach doc logs error using (old) commons jdbc pool 
related to defect 0036001 closed alostale Connection leak after start the system having any servlet with "loaded-on-startup" for example: Analytics module installed 
Issue History
2013-05-22 11:43alostaleNew Issue
2013-05-22 11:43alostaleAssigned To => alostale
2013-05-22 11:43alostaleModules => Core
2013-05-22 11:43alostaleTriggers an Emergency Pack => No
2013-05-22 11:43alostaleRelationship addedrelated to 0023818
2013-05-22 11:44alostaleTag Attached: Performance
2015-03-17 14:38alostaleAssigned Toalostale => platform
2015-11-11 11:11alostaleSummary3 dangling DB connections after Tomcat start => 2 dangling DB connections after Tomcat start
2015-11-11 11:11alostaleDescription Updatedbug_revision_view_page.php?rev_id=10149#r10149
2015-11-11 11:11alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=10151#r10151
2015-11-11 11:12alostaleStatusnew => acknowledged
2016-12-01 14:05alostalePrioritynormal => urgent
2016-12-01 14:05alostalePriorityurgent => high
2017-02-27 10:22caristuRelationship addedrelated to 0035356
2017-03-01 18:05shuehnerNote Added: 0094669
2017-03-02 15:50alostaleAssigned Toplatform => alostale
2017-03-02 15:50alostaleReview Assigned To => caristu
2017-03-02 15:51hgbotCheckin
2017-03-02 15:51hgbotNote Added: 0094689
2017-03-02 15:51hgbotCheckin
2017-03-02 15:51hgbotNote Added: 0094690
2017-03-02 15:51hgbotStatusacknowledged => resolved
2017-03-02 15:51hgbotResolutionopen => fixed
2017-03-02 15:51hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/9534e8e498fde6508ff2bf5988fd05a7da0c3bf2 [^]
2017-03-10 13:37caristuNote Added: 0094916
2017-03-10 13:37caristuStatusresolved => closed
2017-03-10 13:37caristuFixed in Version => 3.0PR17Q2
2017-03-15 20:20hudsonbotCheckin
2017-03-15 20:20hudsonbotNote Added: 0095251
2017-03-15 20:20hudsonbotCheckin
2017-03-15 20:20hudsonbotNote Added: 0095252
2017-05-19 08:06caristuRelationship addedrelated to 0036001
2017-06-19 15:07alostaleRelationship addedduplicate of 0036274

Notes
(0094669)
shuehner   
2017-03-01 18:05   
Possible related stacktrace:
Looks like 3rd line of the connections list mentioned in the issue above.

Mar 01, 2017 4:12:47 PM org.apache.tomcat.jdbc.pool.ConnectionPool suspect
WARNING: Connection has been marked suspect, possibly abandoned PooledConnection[org.postgresql.jdbc.PgConnection@7c9c
        at org.apache.tomcat.jdbc.pool.ConnectionPool.getThreadDump(ConnectionPool.java:1075)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:781)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:632)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:189)
        at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:128)
        at org.openbravo.apachejdbcconnectionpool.JdbcExternalConnectionPool.getConnection(JdbcExternalConnectionPool.
        at org.openbravo.database.ConnectionProviderImpl.getNewConnection(ConnectionProviderImpl.java:263)
        at org.openbravo.database.ConnectionProviderImpl.getConnection(ConnectionProviderImpl.java:236)
        at org.openbravo.database.ConnectionProviderImpl.getPreparedStatement(ConnectionProviderImpl.java:377)
        at org.openbravo.database.ConnectionProviderImpl.getPreparedStatement(ConnectionProviderImpl.java:369)
        at org.openbravo.erpCommon.security.SessionLoginData.deactivateExpiredSessions(SessionLoginData.java:116)
        at org.openbravo.erpCommon.security.SessionListener.contextInitialized(SessionListener.java:127)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5010)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5504)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1229)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
(0094689)
hgbot   
2017-03-02 15:51   
Repository: erp/devel/pi
Changeset: 8acdcdf44a93ae83625052ab798b447701332d52
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Mar 02 15:46:12 2017 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/8acdcdf44a93ae83625052ab798b447701332d52 [^]

related to bug 23882: 2 dangling DB connections after Tomcat start

  One of those leaked connections was used on Tomcat startup by context listeners
  using sqlc, the connection was attached to current thread in SessionInfo but
  never released to pool because this thread is not managed by DalThreadHandler.

  Fixed by manually removing connection from thread after listener execution.

---
M src/org/openbravo/base/SystemStatusListener.java
M src/org/openbravo/erpCommon/security/SessionListener.java
---
(0094690)
hgbot   
2017-03-02 15:51   
Repository: erp/devel/pi
Changeset: 9534e8e498fde6508ff2bf5988fd05a7da0c3bf2
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Mar 02 15:49:51 2017 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/9534e8e498fde6508ff2bf5988fd05a7da0c3bf2 [^]

fixed bug 23882: 2 dangling DB connections after Tomcat start

  When Hibernate session factory is initialized, it creates a pool that is not
  used when working with Tomcat pool, one connection was retained in this pool.

  Now this pool is clean up so that the connection is freed.

  Note this pool is still used when working with old commons dbcp pool, even
  close method is invoked on the pool instance, it's actually only cleaning up
  the connections it might have, so it is still usable.

---
M src/org/openbravo/base/session/SessionFactoryController.java
---
(0094916)
caristu   
2017-03-10 13:37   
Code reviewed + tested OK.
(0095251)
hudsonbot   
2017-03-15 20:20   
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/54e102bef53e [^]
Maturity status: Test
(0095252)
hudsonbot   
2017-03-15 20:20   
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/54e102bef53e [^]
Maturity status: Test