Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036638Openbravo ERPA. Platformpublic2017-08-10 17:162022-02-01 08:08
shuehner 
Triage Platform Base 
normalmajorhave not tried
newopen 
5
 
 
Core
No
0036638: DalConnectionProvider(true) or () in combination with standard xsql causes 1 flush per SQL
DalConnectionProvider class i a 'bridge' between the implicit DAL session/connection and code expecting ConnectionProvider interface.

Main consumer of the last are the auto-generated xsql classes/method.

There is a very bad interaction between the two in case of requesting implicit flush of the DalConnectionProvider.

Problem here is that the flush of the DalConnectionProvider is not just done once per instance creation i.e. in new. But instead inside its getConnection() method so every time that method is called.

Problem is now the following usage:
conn = new DalConnectionProvider(true)
SeguridadData.isRoleClient(conn, String, String)
SeguridadData.isUserRole(conn, String, String)

The xsql classes here are just placeholder, topic applies the same way to any which are not marked as 'connection=true'

Problem is that every such method inside called some variant of getPreparedStament which calls getConnection)

So when reusing the same instance of DalConnectionProvider a new flush is run for every xsql-based sql statement.

That is very non-obvious and seems to contradict the intention of that flush which is:
- flush/apply any pending DAL modifications so they are visible on database level
- before calling any SQL manually on database
- which only require single flush I.e. on the 'new'
- Having flush debugging enabled (i.e. stackTrace per flush as discussed in issue 33606)
- click on the UserInfoWidget
- Click 'apply'

That way:
      boolean result = LoginUtils
          .fillSessionArguments(new DalConnectionProvider(), vars, userId,

new ConnectionProvider requesting flush is created.
Passed to the fillSessionArguments function
which isinside reuses that instance for many small selects
Causing total of 36 flushes to be done for this 1 action:
3621931 [http-bio-8080-exec-9] INFO org.openbravo.dal.core.DalRequestFilter - request= /openbravo/org.openbravo.client.kernel?command=save&_action=org.openbravo.client.application.navigationbarcomponents.UserInfoWidgetActionHandler flushCount: 36 flushTime: 179 of total requestTime: 362

Performance
related to defect 0036636 closed alostale new DalConnectionProvider() causes double flush in 1 case 
related to defect 0037277 closed AtulOpenbravo Change the role in the ERP has performance problems 
related to defect 0037428 new Triage Omni OMS don't use DalConnectionProvider default constructor 
blocks design defect 0036606 new Triage Platform Base Clean up extra not requires flush() calls 
txt 36638-flushes.txt (203,273) 2017-08-10 17:18
https://issues.openbravo.com/file_download.php?file_id=10978&type=bug
Issue History
2017-08-10 17:16shuehnerNew Issue
2017-08-10 17:16shuehnerAssigned To => platform
2017-08-10 17:16shuehnerModules => Core
2017-08-10 17:16shuehnerTriggers an Emergency Pack => No
2017-08-10 17:16shuehnerRelationship addedrelated to 0036636
2017-08-10 17:16shuehnerRelationship addedblocks 0036606
2017-08-10 17:18shuehnerFile Added: 36638-flushes.txt
2017-10-06 11:54shuehnerTag Attached: Performance
2017-10-06 11:56shuehnerSeverityminor => major
2017-11-30 18:23shuehnerRelationship addedrelated to 0037277
2017-12-01 08:03alostaleRelationship addedrelated to 0037428
2022-02-01 08:08alostaleAssigned Toplatform => Triage Platform Base

There are no notes attached to this issue.