Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036574Openbravo ERPY. DBSourceManagerpublic2017-08-02 10:032017-08-03 13:05
alostale 
alostale 
immediatemajorrandom
closedfixed 
5
 
3.0PR17Q33.0PR17Q3 
AugustoMauch
Core
QA functional test
2017-05-25
main
http://code.openbravo.com/erp/devel/pi/rev/49ac427a0d6689181afa29b95d7384f78eab2dca [^]
No
0036574: import sample data can get stuck when executed by multiple threads
Importing sample data concurrently with several threads can cause locks at JVM level due to usage of non thread safe internal caches.

This behavior is unlike to occur, but if it happens, import sample data process lasts forever.
Within a multi-core run: ant install.source

Randomly it can get stuck at importing sample data step.

Checking stack traces (jstack):

"pool-1-thread-2" prio=10 tid=0x00007fac2c83f800 nid=0x4c3a runnable [0x00007fac2203f000]
   java.lang.Thread.State: RUNNABLE
    at java.util.HashMap.getEntry(HashMap.java:465)
    at java.util.HashMap.get(HashMap.java:417)
    at org.apache.ddlutils.dynabean.DynaClassCache.getDynaClass(DynaClassCache.java:99)
    at org.apache.ddlutils.dynabean.DynaClassCache.createNewInstance(DynaClassCache.java:50)
    at org.apache.ddlutils.model.Database.createDynaBeanFor(Database.java:1342)
    at org.apache.ddlutils.io.DynaSqlCreateRule.begin(DynaSqlCreateRule.java:61)
    at org.apache.commons.digester.Digester.startElement(Digester.java:1464)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.commons.digester.Digester.parse(Digester.java:1743)
    at org.apache.ddlutils.io.DatabaseDataIO.writeDataToDatabase(DatabaseDataIO.java:722)
    at org.openbravo.ddlutils.task.ImportSampledata$ImportRunner.importXmlFile(ImportSampledata.java:357)
    at org.openbravo.ddlutils.task.ImportSampledata$ImportRunner.run(ImportSampledata.java:340)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

"pool-1-thread-1" prio=10 tid=0x00007fac2c83f000 nid=0x4c39 runnable [0x00007fac2213f000]
   java.lang.Thread.State: RUNNABLE
    at java.util.HashMap.put(HashMap.java:494)
    at org.apache.ddlutils.dynabean.DynaClassCache.getDynaClass(DynaClassCache.java:103)
    at org.apache.ddlutils.dynabean.DynaClassCache.createNewInstance(DynaClassCache.java:50)
    at org.apache.ddlutils.model.Database.createDynaBeanFor(Database.java:1342)
    at org.apache.ddlutils.io.DynaSqlCreateRule.begin(DynaSqlCreateRule.java:61)
    at org.apache.commons.digester.Digester.startElement(Digester.java:1464)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.commons.digester.Digester.parse(Digester.java:1743)
    at org.apache.ddlutils.io.DatabaseDataIO.writeDataToDatabase(DatabaseDataIO.java:722)
    at org.openbravo.ddlutils.task.ImportSampledata$ImportRunner.importXmlFile(ImportSampledata.java:357)
    at org.openbravo.ddlutils.task.ImportSampledata$ImportRunner.run(ImportSampledata.java:340)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

Both threads are manipulating the same HashMap concurrently causing, in some cases, infinite loop.
No tags attached.
blocks defect 0036573 closed alostale import sample data can get stuck when executed by multiple threads 
Issue History
2017-08-02 10:05alostaleTypedefect => backport
2017-08-02 10:05alostaleTarget Version => 3.0PR17Q3
2017-08-02 10:33hgbotCheckin
2017-08-02 10:33hgbotNote Added: 0098324
2017-08-02 10:33hgbotStatusscheduled => resolved
2017-08-02 10:33hgbotResolutionopen => fixed
2017-08-02 10:33hgbotFixed in SCM revision => http://code.openbravo.com/erp/backports/3.0PR17Q3/rev/fb946104af617509960447687aae64907670e51a [^]
2017-08-02 10:34alostaleReview Assigned To => AugustoMauch
2017-08-03 13:05AugustoMauchNote Added: 0098363
2017-08-03 13:05AugustoMauchStatusresolved => closed
2017-08-03 13:05AugustoMauchFixed in Version => 3.0PR17Q3

Notes
(0098324)
hgbot   
2017-08-02 10:33   
Repository: erp/backports/3.0PR17Q3
Changeset: fb946104af617509960447687aae64907670e51a
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Wed Aug 02 10:30:22 2017 +0200
URL: http://code.openbravo.com/erp/backports/3.0PR17Q3/rev/fb946104af617509960447687aae64907670e51a [^]

fixed bug 36574: import sample data can get stuck if executed concurrently

  It was caused by a concurrent modification/read of cache HashMap in DynaClassCache.

  As getDynaClass is the only method that reads and modifies this internal cache,
  the fix is to make it synchronized.

  Checked also, while importing sample data this is the only place where shared
  objects are modified.

---
M src-db/database/lib/dbsourcemanager.jar
---
(0098363)
AugustoMauch   
2017-08-03 13:05   
Code reviewed and verified