Openbravo Issue Tracking System - Openbravo ERP |
View Issue Details |
|
ID | Project | Category | View Status | Date Submitted | Last Update |
0024421 | Openbravo ERP | A. Platform | public | 2013-07-29 12:26 | 2013-09-27 14:21 |
|
Reporter | alostale | |
Assigned To | alostale | |
Priority | normal | Severity | major | Reproducibility | random |
Status | closed | Resolution | fixed | |
Platform | | OS | 5 | OS Version | |
Product Version | | |
Target Version | 3.0MP28 | Fixed in Version | 3.0MP28 | |
Merge Request Status | |
Review Assigned To | AugustoMauch |
OBNetwork customer | |
Web browser | |
Modules | Core |
Support ticket | |
Regression level | |
Regression date | |
Regression introduced in release | |
Regression introduced by commit | |
Triggers an Emergency Pack | No |
|
Summary | 0024421: ApplicationDictionaryCachedStructures is not thread safe |
Description | ApplicationDictionaryCachedStructures with @SessionScoped has some potential issues when it is accessed concurrently by several threads:
1. It caches BaseOBObject with uninitialized proxies. BaseOBObject are attached to the Hibernate session of the thread that did the request. In case Thread-1 caches one of these objects and closes it's session, and later Thread-2 gets this object and touches any of its uninitialized proxies, org.hibernate.LazyInitializationException exception is thrown, causing FIC not to work properly, user can perceive this by hieratical behavior when working in Opebravo (such as not loading default values when creating new records...)
2. In case Thread-2 gets the object before Thread-1 is done, the object's session is still alive. If at this point, the 2 threads try to concurrently load any of the proxied properties (even they are different ones). Different errors can happen, mainly due to StatefulPersistenceContext using non synchronized HashMap, these error can be NPE, org.hibernate.AssertionFailure: possible non-threadsafe access to the session, java.util.ConcurrentModificationException, org.hibernate.LazyInitializationException: illegal access to loading collection or even to get a processor stuck with 100% CPU usage in HashMap.put or HashMap.get caused by trying to access to an inconsistent Map [1][2].
3. (This case is theoretical as it has not been seen/reported so far). ApplicationDictionaryCachedStructures keeps cache in non synchronized HashMaps which can lead to similar consequences than described in issue 2, in case they are concurrently structurally modified [3].
Note this to happen requires to have concurrent threads in the same session calling FIC.
[1] https://hibernate.atlassian.net/browse/HHH-6414 [^]
[2] https://forum.hibernate.org/viewtopic.php?f=1&t=980460 [^]
[3] http://docs.oracle.com/javase/6/docs/api/java/util/HashMap.html [^] |
Steps To Reproduce | The main candidate to cause this is Business Partner window, because main and Customer tabs are working with the same table and customer tab is single record. When a record is selected in header, FIC request is done for it and immediately another request for it's customer tab. |
Proposed Solution | -Completely initialize cached BaseOBObject when first requested.
-This initialization needs to be synchronized in order to be always correctly completed
-Prevent non synchronized Maps structural modifications in ApplicationDictionaryCachedStructures |
Additional Information | |
Tags | No tags attached. |
Relationships | related to | defect | 0024326 | | closed | alostale | Openbravo ERP | Suboptimal parent tab getter for root tabs | related to | defect | 0024412 | | closed | alostale | Openbravo ERP | Random failures in FIC | related to | defect | 0025310 | 3.0PR14Q2 | closed | alostale | Openbravo ERP | Java processes locked on tomcat | related to | defect | 0026664 | | closed | alostale | Openbravo ERP | Useless ConnectionProvider caching in ApplicationDictionaryCachedStructures | related to | defect | 0028519 | | closed | AugustoMauch | Openbravo ERP | Java-thread apparently deadlocking in OrganizationStructureProvider.initialize | related to | defect | 0029754 | | closed | marvintm | Retail Modules | Concurrent execution of the method generateStaticResources locks the system |
|
Attached Files | 24421.export (22,939) 2013-07-30 10:37 https://issues.openbravo.com/file_download.php?file_id=6296&type=bug |
|
Issue History |
Date Modified | Username | Field | Change |
2013-07-29 12:26 | alostale | New Issue | |
2013-07-29 12:26 | alostale | Assigned To | => AugustoMauch |
2013-07-29 12:26 | alostale | Modules | => Core |
2013-07-29 12:26 | alostale | Triggers an Emergency Pack | => No |
2013-07-29 12:27 | alostale | Relationship added | related to 0024326 |
2013-07-29 12:28 | alostale | Relationship added | related to 0024412 |
2013-07-29 12:31 | alostale | Proposed Solution updated | |
2013-07-29 12:36 | alostale | Description Updated | bug_revision_view_page.php?rev_id=4919#r4919 |
2013-07-29 12:36 | alostale | Target Version | => 3.0MP27 |
2013-07-29 13:10 | egoitz | Issue Monitored: egoitz | |
2013-07-29 14:22 | alostale | Assigned To | AugustoMauch => alostale |
2013-07-30 10:37 | alostale | File Added: 24421.export | |
2013-07-30 10:37 | alostale | Note Added: 0060368 | |
2013-07-30 10:38 | alostale | Note Added: 0060369 | |
2013-08-20 12:10 | AugustoMauch | Target Version | 3.0MP27 => 3.0MP28 |
2013-09-24 17:49 | hgbot | Checkin | |
2013-09-24 17:49 | hgbot | Note Added: 0061369 | |
2013-09-24 17:49 | hgbot | Status | new => resolved |
2013-09-24 17:49 | hgbot | Resolution | open => fixed |
2013-09-24 17:49 | hgbot | Fixed in SCM revision | => http://code.openbravo.com/erp/devel/pi/rev/d40d287ea91a0c156f9087d2d00fa03dd579a543 [^] |
2013-09-24 17:49 | alostale | Review Assigned To | => AugustoMauch |
2013-09-25 19:56 | hudsonbot | Checkin | |
2013-09-25 19:56 | hudsonbot | Note Added: 0061393 | |
2013-09-27 14:21 | AugustoMauch | Note Added: 0061451 | |
2013-09-27 14:21 | AugustoMauch | Status | resolved => closed |
2013-09-27 14:21 | AugustoMauch | Fixed in Version | => 3.0MP28 |
2014-03-21 10:48 | alostale | Relationship added | related to 0025310 |
2014-05-22 14:52 | alostale | Relationship added | related to 0026664 |
2015-01-05 11:16 | shuehner | Relationship added | related to 0028519 |
2015-04-30 18:07 | egoitz | Relationship added | related to 0029754 |
Notes |
|
|
|
|
|
Included within the fix jUnit test cases to verify it |
|
|
(0061369)
|
hgbot
|
2013-09-24 17:49
|
|
Repository: erp/devel/pi
Changeset: d40d287ea91a0c156f9087d2d00fa03dd579a543
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Tue Jul 30 10:36:44 2013 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/d40d287ea91a0c156f9087d2d00fa03dd579a543 [^]
fixed bug 24421, fixed bug 24326: ADCachedStructures thread safe issues
-getTab now completely initializes all tabs in the window
-it is now synchronized
Added test cases to check it
---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ApplicationDictionaryCachedStructures.java
M modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
M src-test/org/openbravo/test/AllAntTaskTests.java
A src-test/org/openbravo/test/base/HiddenObjectHelper.java
A src-test/org/openbravo/test/dal/ADCachedMultiThreadTest.java
---
|
|
|
|
|
|
|
Code reviewed and verified in pi@34a6241c3e04 |
|