Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0039601Openbravo ERPA. Platformpublic2018-11-07 15:032018-12-11 20:22
alostale 
alostale 
immediatemajorrandom
closedfixed 
5
 
3.0PR19Q1 
caristu
Core
Production - Confirmed Stable
2016-08-10
3.0PR16Q4
https://code.openbravo.com/erp/devel/pi/rev/88ea14de1a84e176f457750118a6d4823588d7d2 [^]
No
0039601: can't execute DB updates after killing a connection
With Audit trail active, killing DB connections can cause random failures while trying to update information.

Technically the problem is:
1. Pool keeps PooledConnections each of them associated with a physical DB connection
2. When one of those physical DB connections is killed and a PooledConnection is going to be used (borrowed from the pool), Tomcat transparently creates a new physical connection and associates it with the existing PooledConnection instance.
3. Openbravo, in order not to recreate ad_context_info temporary table on each borrow, does it when a new connection is created and marks it as already initialized. This flag is set in the PooledConnection, incorrectly assuming a PooledConnection instance is always tight to the same Connection instance
4. Because of 2nd step, a new uninitialized Connection is associated with an existing PooledConnection marked as initialized, so queries expecting the temporary table to be present will fail.

This situation remains until the connection is finally returned to the pool.
In a Professional instance:
0. Configure DB pool to a fixed 5 connections:
  db.pool.initialSize=5
  db.pool.minIdle=5
  db.pool.maxActive=5
1. As System Admin open Table window
2. Select any table and mark it as fully audited
3. Restart Tomcat
4. Kill the 5 connections that are in pool: in psql execute select pg_terminate_backend(pid), pid from pg_stat_activity where application_name ='openbravo';
5. Log in
6. Open Process Request window
7. Create a new record and save
  -> Saving failed. ERROR: relation "ad_context_info" does not exist
No tags attached.
depends on backport 00396033.0PR18Q4 closed alostale can't update information after killing a connection 
depends on backport 00396043.0PR18Q3.3 closed alostale can't update information after killing a connection 
caused by defect 00334413.0PR16Q4 closed NaroaIriarte query to check if ad_context_info exists executed once per request 
Issue History
2018-11-07 15:03alostaleNew Issue
2018-11-07 15:03alostaleAssigned To => alostale
2018-11-07 15:03alostaleModules => Core
2018-11-07 15:03alostaleTriggers an Emergency Pack => No
2018-11-07 15:05alostaleRelationship addedcaused by 0033441
2018-11-07 15:06alostaleReview Assigned To => caristu
2018-11-07 15:06alostaleRegression level => Production - Confirmed Stable
2018-11-07 15:06alostaleRegression introduced in release => 3.0PR16Q4
2018-11-07 15:07alostaleRegression date => 2016-08-10
2018-11-07 15:07alostaleRegression introduced by commit => https://code.openbravo.com/erp/devel/pi/rev/88ea14de1a84e176f457750118a6d4823588d7d2 [^]
2018-11-07 15:08alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=17903#r17903
2018-11-07 15:09alostaleStatusnew => scheduled
2018-11-07 15:10alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=17904#r17904
2018-11-07 16:46alostaleSummarycan't update information after killing a connection => can't execute DB updates after killing a connection
2018-11-07 18:57rafademiguelIssue Monitored: rafademiguel
2018-11-08 11:09hgbotCheckin
2018-11-08 11:09hgbotNote Added: 0107798
2018-11-08 11:09hgbotStatusscheduled => resolved
2018-11-08 11:09hgbotResolutionopen => fixed
2018-11-08 11:09hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/e834e74a3c1ab469e8513de70348c59db1d2c18e [^]
2018-11-08 11:09hgbotCheckin
2018-11-08 11:09hgbotNote Added: 0107799
2018-11-08 11:09hgbotCheckin
2018-11-08 11:09hgbotNote Added: 0107800
2018-11-08 11:09hgbotCheckin
2018-11-08 11:09hgbotNote Added: 0107801
2018-11-13 10:49caristuNote Added: 0107876
2018-11-13 10:49caristuStatusresolved => closed
2018-11-13 10:49caristuFixed in Version => 3.0PR19Q1
2018-12-11 20:22hudsonbotCheckin
2018-12-11 20:22hudsonbotNote Added: 0108455
2018-12-11 20:22hudsonbotCheckin
2018-12-11 20:22hudsonbotNote Added: 0108456
2018-12-11 20:22hudsonbotCheckin
2018-12-11 20:22hudsonbotNote Added: 0108457
2018-12-11 20:22hudsonbotCheckin
2018-12-11 20:22hudsonbotNote Added: 0108458

Notes
(0107798)
hgbot   
2018-11-08 11:09   
Repository: erp/devel/pi
Changeset: e834e74a3c1ab469e8513de70348c59db1d2c18e
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Nov 08 10:19:51 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/e834e74a3c1ab469e8513de70348c59db1d2c18e [^]

fixed bug 39601: can't execute DB updates after killing a connection

  Audit Trail infrastructure (ad_context_info in PG) is initialized each time a
  new connection is created. We incorrectly assumed a PooledConnection is always
  associated with a single Connection instance, which is not true in case Connection
  gets corrupted or killed, in this case Tomcat pool transparently re-associates
  a new connection with existent PooledConnection.

  We are now caching in PooledConnection actual Connection to detect this case
  so it can be initialized again.

---
M modules/org.openbravo.apachejdbcconnectionpool/src/org/openbravo/apachejdbcconnectionpool/ConnectionInitializerInterceptor.java
---
(0107799)
hgbot   
2018-11-08 11:09   
Repository: erp/devel/pi
Changeset: 2ef2c5233cab721eb5a786bfcd49bc054d05f59b
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Nov 08 10:47:32 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/2ef2c5233cab721eb5a786bfcd49bc054d05f59b [^]

related with bug 39601: minor code cleanup

---
M modules/org.openbravo.apachejdbcconnectionpool/src/org/openbravo/apachejdbcconnectionpool/ConnectionInitializerInterceptor.java
---
(0107800)
hgbot   
2018-11-08 11:09   
Repository: erp/devel/pi
Changeset: f55cbe0219f90db361464237f1c296ab2b82aa76
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Nov 08 10:57:00 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/f55cbe0219f90db361464237f1c296ab2b82aa76 [^]

related with bug 39601: let it fail if ad_context info couldn't be created

---
M src-core/src/org/openbravo/database/SessionInfo.java
---
(0107801)
hgbot   
2018-11-08 11:09   
Repository: erp/devel/pi
Changeset: 847353facd72c92a1936a239c428ce4964633f55
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Nov 08 10:59:02 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/847353facd72c92a1936a239c428ce4964633f55 [^]

related with bug 39601: minor code cleanup

---
M src-core/src/org/openbravo/database/SessionInfo.java
---
(0107876)
caristu   
2018-11-13 10:49   
Code reviewed + tested OK.
(0108455)
hudsonbot   
2018-12-11 20:22   
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/470e3cd384c5 [^]
Maturity status: Test
(0108456)
hudsonbot   
2018-12-11 20:22   
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/470e3cd384c5 [^]
Maturity status: Test
(0108457)
hudsonbot   
2018-12-11 20:22   
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/470e3cd384c5 [^]
Maturity status: Test
(0108458)
hudsonbot   
2018-12-11 20:22   
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/470e3cd384c5 [^]
Maturity status: Test