Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0037677Openbravo ERPA. Platformpublic2018-01-19 10:072018-02-22 18:18
AugustoMauch 
AugustoMauch 
normalminorhave not tried
closedfixed 
5
 
3.0PR18Q2 
caristu
Core
No
0037677: No need to check if ad_context_info table exists before creating it
The SessionInfo.initDB method creates the ad_context_info temporary table in postgres [1]. Before creating it, it consults the catalog to check if the table has already been created.

This method used to be called each time a connection was borrowed from the pool, but this behaviour changed in this issue [2], now it is invoked only when a physical connection is created in the database. This makes unnecessary to check if the temporary table has been created.

In a high concurrency environment, the query to check if the table exists took longer than 40 seconds, in a peak where lots of connections were created in a short time span.

[1] https://code.openbravo.com/erp/devel/pi/file/tip/src-core/src/org/openbravo/database/SessionInfo.java#l123 [^]
[2] https://issues.openbravo.com/view.php?id=33441 [^]
- Write log before this line [1], printing the result of the query. It will always return 0, making the query unnecessary.

[1] https://code.openbravo.com/erp/devel/pi/file/tip/src-core/src/org/openbravo/database/SessionInfo.java#l128 [^]
Performance
related to defect 00334413.0PR16Q4 closed NaroaIriarte query to check if ad_context_info exists executed once per request 
related to feature request 0037681 closed AugustoMauch No need to create the ad_context_info table if audit trail is not active, remove Update Audit Trail Infrastructure. 
Issue History
2018-01-19 10:07AugustoMauchNew Issue
2018-01-19 10:07AugustoMauchAssigned To => AugustoMauch
2018-01-19 10:07AugustoMauchModules => Core
2018-01-19 10:07AugustoMauchTriggers an Emergency Pack => No
2018-01-19 10:16AugustoMauchRelationship addedrelated to 0033441
2018-01-19 10:17AugustoMauchSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=16559#r16559
2018-01-19 10:28AugustoMauchRelationship addedrelated to 0037681
2018-01-29 10:32alostaleTag Attached: Performance
2018-02-01 13:13hgbotCheckin
2018-02-01 13:13hgbotNote Added: 0102116
2018-02-01 13:13hgbotStatusnew => resolved
2018-02-01 13:13hgbotResolutionopen => fixed
2018-02-01 13:13hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/a2cba155ca8ff6c03009eead9a94a21e7c78823a [^]
2018-02-01 13:14AugustoMauchReview Assigned To => caristu
2018-02-02 10:08caristuNote Added: 0102145
2018-02-02 10:08caristuStatusresolved => closed
2018-02-02 10:08caristuFixed in Version => 3.0PR18Q2
2018-02-22 18:18hudsonbotCheckin
2018-02-22 18:18hudsonbotNote Added: 0102705

Notes
(0102116)
hgbot   
2018-02-01 13:13   
Repository: erp/devel/pi
Changeset: a2cba155ca8ff6c03009eead9a94a21e7c78823a
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Fri Jan 19 11:58:05 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/a2cba155ca8ff6c03009eead9a94a21e7c78823a [^]

Fixes issue 37677: Dont check if ad_context_info table exists before creating it

Now, if the pool is used, the query to check if the ad_context_info table already exists will not be done. This check can be skipped because
if the pool is used, the initDB method will only be called when a new physical connection is created, and in that case the temporary table is
garanteed not to exist.

This pool instance check is needed to keep supporting using pools other than org.openbravo.apachejdbcconnectionpool.JdbcExternalConnectionPool (or none at al),
but in those cases the query to check if the ad_context_info table exists will still be performed.

---
M src-core/src/org/openbravo/database/SessionInfo.java
---
(0102145)
caristu   
2018-02-02 10:08   
Code reviewed.
(0102705)
hudsonbot   
2018-02-22 18:18   
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/980a6ad5bbf5 [^]
Maturity status: Test