Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036274Openbravo ERPA. Platformpublic2017-06-19 15:042017-06-23 11:04
alostale 
alostale 
normalminorhave not tried
closedfixed 
5
 
3.0PR17Q3 
caristu
Core
No
0036274: abandoned connection in SessionListener
Two cases:

1.

When a session is expired due to Tomcat's session timeout by SessionListener, the DB connection used in this thread is never returned to pool.

Note this occurs in case the actual thread invalidating the session is ContainerBackgroundProcessor. If it is invalidated through SessionExpirationFilter, the connection is correctly returned to pool. Latter case occurs ie. alert ping happens.

2.
When Tomcat is shut down having active sessions.
1.1. Configure pool to log abandoned connections
1.2. Log in Openbravo
1.3. Close browser used to login (to prevent alert ping to invalidate session)
1.4. Wait until session expires due to time out
 -> check log:
Jun 19, 2017 2:55:42 PM org.apache.tomcat.jdbc.pool.ConnectionPool suspect
WARNING: Connection has been marked suspect, possibly abandoned PooledConnection[org.postgresql.jdbc.PgConnection@4b3fb2fb][10482 ms.]:java.lang.Exception
    at org.apache.tomcat.jdbc.pool.ConnectionPool.getThreadDump(ConnectionPool.java:1096)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:799)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:648)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:200)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:128)
    at org.openbravo.apachejdbcconnectionpool.JdbcExternalConnectionPool.getConnectionFromDS(JdbcExternalConnectionPool.java:130)
    at org.openbravo.apachejdbcconnectionpool.JdbcExternalConnectionPool.getConnection(JdbcExternalConnectionPool.java:93)
    at org.openbravo.database.ConnectionProviderImpl.getNewConnection(ConnectionProviderImpl.java:260)
    at org.openbravo.database.ConnectionProviderImpl.getConnection(ConnectionProviderImpl.java:236)
    at org.openbravo.database.ConnectionProviderImpl.getPreparedStatement(ConnectionProviderImpl.java:369)
    at org.openbravo.database.ConnectionProviderImpl.getPreparedStatement(ConnectionProviderImpl.java:361)
    at org.openbravo.erpCommon.security.SessionLoginData.deactivate(SessionLoginData.java:81)
    at org.openbravo.erpCommon.security.SessionListener.deactivateSession(SessionListener.java:195)
    at org.openbravo.erpCommon.security.SessionListener.sessionDestroyed(SessionListener.java:65)

---

2.1 Configure pool to log abandoned connections
2.2 Log in Openbravo
2.3 Stop tomcat
  -> check log:
Jun 19, 2017 3:04:24 PM org.apache.tomcat.jdbc.pool.ConnectionPool abandon
WARNING: Connection has been abandoned PooledConnection[org.postgresql.jdbc.PgConnection@744cf1bd]:java.lang.Exception
    at org.apache.tomcat.jdbc.pool.ConnectionPool.getThreadDump(ConnectionPool.java:1096)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:799)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:648)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:200)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:128)
    at org.openbravo.apachejdbcconnectionpool.JdbcExternalConnectionPool.getConnectionFromDS(JdbcExternalConnectionPool.java:130)
    at org.openbravo.apachejdbcconnectionpool.JdbcExternalConnectionPool.getConnection(JdbcExternalConnectionPool.java:93)
    at org.openbravo.database.ConnectionProviderImpl.getNewConnection(ConnectionProviderImpl.java:260)
    at org.openbravo.database.ConnectionProviderImpl.getConnection(ConnectionProviderImpl.java:236)
    at org.openbravo.database.ConnectionProviderImpl.getPreparedStatement(ConnectionProviderImpl.java:369)
    at org.openbravo.database.ConnectionProviderImpl.getPreparedStatement(ConnectionProviderImpl.java:361)
    at org.openbravo.erpCommon.security.SessionLoginData.deactivate(SessionLoginData.java:81)
Performance
related to defect 0036261 closed alostale connections logged as abandoned in translate task 
has duplicate defect 0023882 closed alostale 2 dangling DB connections after Tomcat start 
Issue History
2017-06-19 15:04alostaleNew Issue
2017-06-19 15:04alostaleAssigned To => alostale
2017-06-19 15:04alostaleModules => Core
2017-06-19 15:04alostaleTriggers an Emergency Pack => No
2017-06-19 15:04alostaleTag Attached: Performance
2017-06-19 15:07alostaleRelationship addedhas duplicate 0023882
2017-06-19 15:10alostaleRelationship addedrelated to 0036261
2017-06-19 15:17hgbotCheckin
2017-06-19 15:17hgbotNote Added: 0097478
2017-06-19 15:17hgbotStatusnew => resolved
2017-06-19 15:17hgbotResolutionopen => fixed
2017-06-19 15:17hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/cfd3f8102b4a1b9b3382a70128459cd258835ffa [^]
2017-06-20 09:23alostaleReview Assigned To => caristu
2017-06-20 16:31hudsonbotCheckin
2017-06-20 16:31hudsonbotNote Added: 0097518
2017-06-23 11:04caristuNote Added: 0097602
2017-06-23 11:04caristuStatusresolved => closed
2017-06-23 11:04caristuFixed in Version => 3.0PR17Q3

Notes
(0097478)
hgbot   
2017-06-19 15:17   
Repository: erp/devel/pi
Changeset: cfd3f8102b4a1b9b3382a70128459cd258835ffa
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Mon Jun 19 15:16:26 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/cfd3f8102b4a1b9b3382a70128459cd258835ffa [^]

fixed bug 36274: abandoned connection in SessionListener

  Detach connection from current thread to allow it to be properly returned
  to pool.

  This is required whever the thread doing the actio is not handling an standard
  request.

---
M src/org/openbravo/erpCommon/security/SessionListener.java
---
(0097518)
hudsonbot   
2017-06-20 16:31   
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/8518c867b17c [^]
Maturity status: Test
(0097602)
caristu   
2017-06-23 11:04   
Code reviewed