Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0037277Openbravo ERP01. General setuppublic2017-11-13 10:092018-01-03 12:39
Sandrahuguet 
AtulOpenbravo 
normalmajorhave not tried
closedfixed 
30Openbravo Appliance 14.04
 
3.0PR18Q1 
vmromanos
Core
No
0037277: Change the role in the ERP has performance problems
In an environment with many organizations, get General Ledger of context organizations part in LoginUtils.java (specifically, the loop by organization and selectAcctSchema inside) is very slow (takes around 17s).

slow part:

        // Get General Ledger of context organizations
        if (ArrayUtils.isEmpty(attr)) {
          String[] orgList = Utility.getContext(conn, vars, "#User_Org", "LoginHandler")
              .replace("'", "").split(",");
          for (String orgId : orgList) {
            if (!StringUtils.equals(orgId, strOrg)) {
              acctSchemaId = OBLedgerUtils.getOrgLedger(orgId);
              if (StringUtils.isNotEmpty(acctSchemaId)) {
                attr = AttributeData.selectAcctSchema(conn, acctSchemaId,
                    Utility.getContext(conn, vars, "#User_Client", "LoginHandler"));
                if (ArrayUtils.isNotEmpty(attr)) {
                  break;
                }
              }
            }
          }
        }
Login in the ERP
Open developer tools
Change the role to a role with access to many organizations
Notice that UserInfoWidgetActionHandler request takes around 18s
Performance
related to design defect 0036638 new Triage Platform Base DalConnectionProvider(true) or () in combination with standard xsql causes 1 flush per SQL 
depends on backport 00374563.0PR17Q4 closed AtulOpenbravo Change the role in the ERP has performance problems 
depends on backport 00374573.0PR17Q3.2 closed AtulOpenbravo Change the role in the ERP has performance problems 
related to defect 0037455 scheduled AtulOpenbravo Detected slow piece of code in LoginUtils 
? createOrg.sql (2,297) 2017-11-27 06:54
https://issues.openbravo.com/file_download.php?file_id=11320&type=bug
diff issue-37277.diff (1,102) 2017-11-30 18:23
https://issues.openbravo.com/file_download.php?file_id=11347&type=bug
Issue History
2017-11-13 10:09SandrahuguetNew Issue
2017-11-13 10:09SandrahuguetAssigned To => Triage Finance
2017-11-13 10:09SandrahuguetModules => Core
2017-11-13 10:09SandrahuguetTriggers an Emergency Pack => No
2017-11-13 10:10SandrahuguetTag Attached: Performance
2017-11-13 10:18SandrahuguetResolution time => 1512342000
2017-11-13 10:20SandrahuguetDescription Updatedbug_revision_view_page.php?rev_id=16269#r16269
2017-11-13 10:23SandrahuguetDescription Updatedbug_revision_view_page.php?rev_id=16270#r16270
2017-11-13 11:14SandrahuguetDescription Updatedbug_revision_view_page.php?rev_id=16271#r16271
2017-11-13 18:11dmiguelezAssigned ToTriage Finance => collazoandy4
2017-11-14 12:52dmiguelezAssigned Tocollazoandy4 => AtulOpenbravo
2017-11-21 15:33AtulOpenbravoStatusnew => scheduled
2017-11-27 06:53AtulOpenbravoNote Added: 0100719
2017-11-27 06:54AtulOpenbravoFile Added: createOrg.sql
2017-11-29 22:37AtulOpenbravoNote Added: 0100815
2017-11-30 18:23shuehnerFile Added: issue-37277.diff
2017-11-30 18:23shuehnerRelationship addedrelated to 0036638
2017-12-01 12:53AtulOpenbravoNote Added: 0100893
2017-12-01 12:54AtulOpenbravoNote Edited: 0100893bug_revision_view_page.php?bugnote_id=0100893#r16418
2017-12-12 10:15AtulOpenbravoIssue cloned0037455
2017-12-12 10:15AtulOpenbravoRelationship addedrelated to 0037455
2017-12-12 10:16AtulOpenbravoStatusscheduled => acknowledged
2017-12-12 10:17AtulOpenbravoStatusacknowledged => scheduled
2017-12-12 10:19AtulOpenbravoNote Added: 0100974
2017-12-12 12:09hgbotCheckin
2017-12-12 12:09hgbotNote Added: 0100982
2017-12-12 12:09hgbotStatusscheduled => resolved
2017-12-12 12:09hgbotResolutionopen => fixed
2017-12-12 12:09hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/1f0a3515e2b9bfe2b894e7f40ef07f4930118d8d [^]
2017-12-12 12:11vmromanosReview Assigned To => vmromanos
2017-12-12 12:11vmromanosStatusresolved => closed
2017-12-12 12:11vmromanosFixed in Version => 3.0PR18Q1
2017-12-14 12:17vmromanosSeveritymajor => minor
2017-12-14 12:17vmromanosSummaryChange the role in the ERP has performance problems => Detected slow piece of code in LoginUtils
2017-12-14 12:17vmromanosDescription Updatedbug_revision_view_page.php?rev_id=16446#r16446
2017-12-14 12:17vmromanosSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=16448#r16448
2017-12-14 12:18vmromanosSeverityminor => major
2017-12-14 12:18vmromanosDescription Updatedbug_revision_view_page.php?rev_id=16449#r16449
2017-12-14 12:18vmromanosSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=16450#r16450
2017-12-14 12:20vmromanosSummaryDetected slow piece of code in LoginUtils => Change the role in the ERP has performance problems
2018-01-03 12:39hudsonbotCheckin
2018-01-03 12:39hudsonbotNote Added: 0101519

Notes
(0100719)
AtulOpenbravo   
2017-11-27 06:53   
Test Plan A

- Create organization using attached createOrg script.
- In LoginUtils add time log statement for the loop in the issue.
- Login as F&B International Group admin.
- Switch role to System Admin
- Set session preferences using Change Logs for LoginUtils class as DEBUG
- Switch role to F&B international Group Admin
- Check in logged timings. It is around ~ 300+ ms

Apply the fix for issue. Flow above steps of enabling preferences and switching the role.
- Check the logged timings. It is around 1 to 4 ms


Test Plan B

- Create General Ledger Configuration records as below
 - 001 Test Ledger 37277. Assign this F&B Espana Norte Region
 - 002 Test Ledger 37277. Assign this F&B Espana Sur Region
 - 003 Test Ledger 37277. Assign this F&B Espana
- Make sure that all ledgers does not have any dimension active.
- Realize/Set F&B International Group organization with General Ledger as "F&B International Group US/A/US Dollar"
- Realize/Set that above "F&B International Group US/A/US Dollar" general ledger has active elements.
- Create a new role "001 Test Role 32277" with organization access to only "F&B Espana Norte Region"
- Assign User Openbravo to it. Add Business Partner window in Window Access Tab
- Logout and Login again with Openbravo User.
- Switch Role to "001 Test Role 32277".
- Realize that General Ledger for F&B International Group is choosed for attr
   as it is in parent list of "F&B Espana Norte Region" and has active elements.
(0100815)
AtulOpenbravo   
2017-11-29 22:37   
Test Plan C

- Login as F&B International Group Admin.
- In General Ledger configuration, make sure that both the general ledgers should have not any active elements in Dimension tab.
- Create a new General Ledger and create at least one active element in dimension tab.
- Try switching role from F&B International Group Admin to System Admin and again back to F&B International Group Admin
- Realize that new general ledger having active elements should be considered by the loop which gets general ledger from context orgs.
(0100893)
AtulOpenbravo   
2017-12-01 12:53   
(edited on: 2017-12-01 12:54)
Time logs before fix, when switching from System Admin to BUT Admin role

Code Level :Loop which traverses through organization list takes

            Run#1. 14820 ms
            Run#2. 14756 ms
            Run#3. 14487 ms
 
UI Level : 20-23 seconds

After the fix

Code Level
           Run#1. 1 ms
           Run#2. 1 ms
           Run#3. 1 ms

UI Level : 8-9 seconds

(0100974)
AtulOpenbravo   
2017-12-12 10:19   
Time logs in local instance with similar setup as in client environment

500+ organizations with General Ledger having no dimensions or no active dimensions defined.

Before any Fix
At first login
Time taken to fetch general ledger of context org (ms):- 426
Time taken to fetch general ledger of context org (ms):- 464

Changing role from System Admin to Client Admin
Run#1
Time taken to fetch general ledger of context org (ms):- 7587
Run#2
Time taken to fetch general ledger of context org (ms):- 7191
Run#3
Time taken to fetch general ledger of context org (ms):- 7134
Run#4
Time taken to fetch general ledger of context org (ms):- 6800

GUI: ~ 8.5 to 9 seconds

After Fix issue-37277.diff
At first login
Time taken to fetch general ledger of context org (ms):- 448
Time taken to fetch general ledger of context org (ms):- 537
Changing role from System Admin to Client Admin

Run#1
Time taken to fetch general ledger of context org (ms):- 215 Org count visited..541
Run#2
Time taken to fetch general ledger of context org (ms):- 196 Org count visited..541
Run#3
Time taken to fetch general ledger of context org (ms):- 213 Org count visited..541
Run#4
Time taken to fetch general ledger of context org (ms):- 153 Org count visited..541

GUI: ~ 2.5 to 3 seconds


With both the fixes
At first login
Total Time (ms): General Ledger of context organizations: 110

Changing role from System Admin to Client Admin
Run#1
Total Time (ms): General Ledger of context organizations: 97
Run#2
Total Time (ms): General Ledger of context organizations: 73
Run#3
Total Time (ms): General Ledger of context organizations: 55
Run#4
Total Time (ms): General Ledger of context organizations: 54

GUI: ~ 2 to 2.5 seconds
(0100982)
hgbot   
2017-12-12 12:09   
Repository: erp/devel/pi
Changeset: 1f0a3515e2b9bfe2b894e7f40ef07f4930118d8d
Author: Atul Gaware <atul.gaware <at> openbravo.com>
Date: Tue Dec 12 14:56:33 2017 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/1f0a3515e2b9bfe2b894e7f40ef07f4930118d8d [^]

Fixes Issue 37277:Change the role in the ERP has performance
problems

** Flush is called before calling fillSessionArguments
** new ConnectionProvider without flush is passed to the
fillSessionArguments method which avoids flush for
every select statement which uses this connection Provider
as flush is not need for select statements.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/navigationbarcomponents/UserInfoWidgetActionHandler.java
---
(0101519)
hudsonbot   
2018-01-03 12:39   
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/c81e0d3cbab5 [^]
Maturity status: Test