Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0029967Openbravo ERPA. Platformpublic2015-05-21 17:532022-02-01 08:09
ioritzCia 
Triage Platform Base 
highmajoralways
acknowledgedopen 
30Ubuntu 14.04
3.0PR15Q1.3 
 
Google Chrome
Core
No
0029967: Hibernate makes tomcat to block many concurrent DAL calls
In a development which makes a lot of concurrent DAL calls. If you execute jstack you can see a lot of blocked calls to java.lang.Class.forName0(Native Method) method inside org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192).

Find attached a jstack file.
Develop a class that executes a DAL query and execute it concurrently several times.

We have an environment and a jmeter test that can make reproducing this easier.
Performance
? jstackBlocked (143,726) 2015-05-21 17:53
https://issues.openbravo.com/file_download.php?file_id=8108&type=bug
Issue History
2015-05-21 17:53ioritzCiaNew Issue
2015-05-21 17:53ioritzCiaAssigned To => platform
2015-05-21 17:53ioritzCiaFile Added: jstackBlocked
2015-05-21 17:53ioritzCiaWeb browser => Google Chrome
2015-05-21 17:53ioritzCiaModules => Core
2015-05-21 17:53ioritzCiaTriggers an Emergency Pack => No
2015-05-21 17:54ioritzCiaTag Attached: Performance
2015-05-21 18:11shuehnerNote Added: 0077630
2015-05-21 18:11shuehnerIssue Monitored: shuehner
2015-05-21 18:50mtaalNote Added: 0077634
2015-05-25 12:42jonalegriaesarteWeb browserGoogle Chrome => Google Chrome
2015-05-25 12:42jonalegriaesarteResolution time => 1435183200
2015-07-02 12:20alostaleWeb browserGoogle Chrome => Google Chrome
2015-07-02 12:20alostaleResolution time1435183200 =>
2015-07-02 12:20alostaleNote Added: 0078624
2015-07-02 12:20alostaleStatusnew => acknowledged
2015-07-02 12:20alostaleTypedefect => design defect
2022-02-01 08:09alostaleAssigned Toplatform => Triage Platform Base

Notes
(0077630)
shuehner   
2015-05-21 18:11   
I think interesting part of the attached file i starting line:
"TP-Processor152" daemon prio=10 tid=0x00007eff441c2000 nid=0x15ef waiting for monitor entry [0x00007effe8ae1000]

The lines before i think are not relevant for the issue.

Starting that line you can see triggering stacktrace + also the contented lock which seems to be part of tomcat classloader being used indirectly (and apparently on every dal call)
(0077634)
mtaal   
2015-05-21 18:50   
There is this code in SessionImpl:
    public List list(CriteriaImpl criteria) throws HibernateException {
        errorIfClosed();
        checkTransactionSynchStatus();
        String[] implementors = factory.getImplementors( criteria.getEntityOrClassName() );

See the last line. I checked if there was a way to override/replace the factory but this will be somewhat difficult I think.

I guess it is a Hibernate bug...

I checked and the only place in the SessionImpl where the getImplementors is called is in this method.

Probably a workaround is to rewrite the custom code to not use a Criteria but a hibernate Query object. Should be quite doable.

gr. Martin
(0078624)
alostale   
2015-07-02 12:20   
Moving to design defect because of the difficulty and risk of this fix. Use the workaround for these cases for now.