Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0024421
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] A. Platformmajorrandom2013-07-29 12:262013-09-27 14:21
ReporteralostaleView Statuspublic 
Assigned Toalostale 
PrioritynormalResolutionfixedFixed in Version3.0MP28
StatusclosedFix in branchFixed in SCM revisiond40d287ea91a
ProjectionnoneETAnoneTarget Version3.0MP28
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned ToAugustoMauch
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0024421: ApplicationDictionaryCachedStructures is not thread safe

DescriptionApplicationDictionaryCachedStructures 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 ReproduceThe 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
TagsNo tags attached.
Attached Files? file icon 24421.export [^] (22,939 bytes) 2013-07-30 10:37

- Relationships Relation Graph ] Dependency Graph ]
related to defect 0024326 closedalostale Openbravo ERP Suboptimal parent tab getter for root tabs 
related to defect 0024412 closedalostale Openbravo ERP Random failures in FIC 
related to defect 00253103.0PR14Q2 closedalostale Openbravo ERP Java processes locked on tomcat 
related to defect 0026664 closedalostale Openbravo ERP Useless ConnectionProvider caching in ApplicationDictionaryCachedStructures 
related to defect 0028519 closedAugustoMauch Openbravo ERP Java-thread apparently deadlocking in OrganizationStructureProvider.initialize 
related to defect 0029754 closedmarvintm Retail Modules Concurrent execution of the method generateStaticResources locks the system 

-  Notes
(0060368)
alostale (manager)
2013-07-30 10:37

Attached fix
(0060369)
alostale (manager)
2013-07-30 10:38

Included within the fix jUnit test cases to verify it
(0061369)
hgbot (developer)
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
---
(0061393)
hudsonbot (developer)
2013-09-25 19:56

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/a06bf757c7ec [^]

Maturity status: Test
(0061451)
AugustoMauch (administrator)
2013-09-27 14:21

Code reviewed and verified in pi@34a6241c3e04

- 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 View Revisions
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


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker