Project:
View Issue Details[ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
ID | ||||||||
0033816 | ||||||||
Type | Category | Severity | Reproducibility | Date Submitted | Last Update | |||
defect | [Openbravo ERP] A. Platform | major | have not tried | 2016-08-25 16:18 | 2016-12-23 08:44 | |||
Reporter | caristu | View Status | public | |||||
Assigned To | caristu | |||||||
Priority | urgent | Resolution | fixed | Fixed in Version | 3.0PR17Q1 | |||
Status | closed | Fix in branch | Fixed in SCM revision | 8a7ca1c913ed | ||||
Projection | none | ETA | none | Target Version | ||||
OS | Any | Database | Any | Java version | ||||
OS Version | Database version | Ant version | ||||||
Product Version | SCM revision | |||||||
Review Assigned To | alostale | |||||||
Web browser | ||||||||
Modules | Core | |||||||
Regression level | ||||||||
Regression date | ||||||||
Regression introduced in release | ||||||||
Regression introduced by commit | ||||||||
Triggers an Emergency Pack | No | |||||||
Summary | 0033816: Find a complete solution to protect OBCriteria.initialize() against multiple calls per instance | |||||||
Description | OBCriteria has an internal initialize() method which adds the usual client,org,isactive filters. However that initialize() method is not protected against multiple calls per instance. So calling it more than once adds those filters also multiple times. Several are at least 2 sequences triggering this a.) call .count() + .uniqueResult() manually from application as seen i.e. in WebPOS OrderLoader: final OBCriteria<Locator> locators = OBDal.getInstance().createCriteria(Locator.class); locators.add(Restrictions.eq(Locator.PROPERTY_ACTIVE, true)); locators.add(Restrictions.eq(Locator.PROPERTY_WAREHOUSE, shipment.getWarehouse())); // note the count causes a query but the good thing is that it doesn't cause loading // additional bin locations if there are too many if (locators.count() == 1) { foundSingleBin = (Locator) locators.uniqueResult(); b.) But also .count() implementation itself calls initialize() and then uniqueResult() (calling it again). | |||||||
Steps To Reproduce | Trace all SQL's done by OrderLoader starting at part in createShipmentLines if (locators.count() == 1) { foundSingleBin = (Locator) locators.uniqueResult(); That SQL run by the .count() already has 3 blocks of the client+org filters happening (2 copies by this bug) + additional one reported as issue 33132. Then the next SQL run by the manual uniqueResult added 2 more copies of the filters. (one by itself and maybe 2nd one because of that same 33132). | |||||||
Proposed Solution | Add isInitialized boolean or similar to OBCriteria.initialize(). Take into account the possible reuse of the OBCriteria instance after fired a query. Solution applied on issue 33138 was reverted on issue 33814 as it was not complete. | |||||||
Tags | No tags attached. | |||||||
Attached Files | ||||||||
Relationships [ Relation Graph ] [ Dependency Graph ] | ||||||||||||||||||||||
|
Notes | |
(0092757) hgbot (developer) 2016-12-19 10:37 |
Repository: erp/devel/pi Changeset: 8a7ca1c913edeb3aeb8ce0ed21748da90e234835 Author: Carlos Aristu <carlos.aristu <at> openbravo.com> Date: Mon Dec 19 10:34:03 2016 +0100 URL: http://code.openbravo.com/erp/devel/pi/rev/8a7ca1c913edeb3aeb8ce0ed21748da90e234835 [^] fixed issue 33816: OBCriteria adds standard filters several time In some cases (ie. in count method), OBCriteria adds the standard filters for client, org and active several times. This problem is caused because initialize method can be invoked several times on the same criteria instance adding each time those filters. This is fixed now by using two flags: - initialize: is set on 1st initialization and it is used to check if the criteria instance has already been initialized. - modified: it is used to identify if the criteria instance has been modified (by changing some filter or the order by clause) after being initialized. If it is false, we will exit the method without executing any action. Otherwise, the initialization will be done again. In this case a warning will be thrown in the log, informing that the generated qquery will have duplicated filters. Note that still OBCriteria is not thread safe: several parallel initialization in the same instance could clash --- M src-test/src/org/openbravo/test/dal/DalTest.java M src/org/openbravo/dal/service/OBCriteria.java --- |
(0092792) hudsonbot (developer) 2016-12-19 23:17 |
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/8c51303887c8 [^] Maturity status: Test |
(0092957) alostale (manager) 2016-12-23 08:44 |
code reviewed tested: 1. normal case: just once initialization 2. after executing query config is changed, second initialization is performed (ensuring backwards compatibility) and a warning is seen in logs |
Issue History | |||
Date Modified | Username | Field | Change |
2016-08-25 16:18 | caristu | New Issue | |
2016-08-25 16:18 | caristu | Assigned To | => alostale |
2016-08-25 16:18 | caristu | Modules | => Core |
2016-08-25 16:18 | caristu | Triggers an Emergency Pack | => No |
2016-08-25 16:18 | caristu | Issue generated from | 0033138 |
2016-08-25 16:18 | caristu | Assigned To | alostale => platform |
2016-08-25 16:18 | caristu | Relationship added | related to 0033814 |
2016-08-26 08:07 | caristu | Relationship added | related to 0033138 |
2016-08-26 08:08 | caristu | Summary | OBCriteria.initialize() is not protected against multiple calls per instance => Find a complete solution to protect OBCriteria.initialize() against multiple calls per instance |
2016-08-26 08:08 | caristu | Proposed Solution updated | |
2016-12-01 13:14 | alostale | Status | new => acknowledged |
2016-12-01 13:17 | alostale | Priority | normal => urgent |
2016-12-01 14:30 | alostale | Assigned To | platform => caristu |
2016-12-16 14:33 | caristu | Status | acknowledged => scheduled |
2016-12-19 10:21 | caristu | Relationship added | related to 0033767 |
2016-12-19 10:37 | hgbot | Checkin | |
2016-12-19 10:37 | hgbot | Note Added: 0092757 | |
2016-12-19 10:37 | hgbot | Status | scheduled => resolved |
2016-12-19 10:37 | hgbot | Resolution | open => fixed |
2016-12-19 10:37 | hgbot | Fixed in SCM revision | => http://code.openbravo.com/erp/devel/pi/rev/8a7ca1c913edeb3aeb8ce0ed21748da90e234835 [^] |
2016-12-19 10:52 | caristu | Review Assigned To | => alostale |
2016-12-19 10:52 | caristu | Issue Monitored: alostale | |
2016-12-19 23:17 | hudsonbot | Checkin | |
2016-12-19 23:17 | hudsonbot | Note Added: 0092792 | |
2016-12-23 08:44 | alostale | Note Added: 0092957 | |
2016-12-23 08:44 | alostale | Status | resolved => closed |
2016-12-23 08:44 | alostale | Fixed in Version | => 3.0PR17Q1 |
Copyright © 2000 - 2009 MantisBT Group |