Openbravo Issue Tracking System - Openbravo ERP | ||||||||||||
View Issue Details | ||||||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | |||||||
0037115 | Openbravo ERP | A. Platform | public | 2017-10-19 13:11 | 2017-11-20 12:43 | |||||||
Reporter | alostale | |||||||||||
Assigned To | alostale | |||||||||||
Priority | normal | Severity | minor | Reproducibility | have not tried | |||||||
Status | closed | Resolution | fixed | |||||||||
Platform | OS | 5 | OS Version | |||||||||
Product Version | ||||||||||||
Target Version | Fixed in Version | 3.0PR18Q1 | ||||||||||
Merge Request Status | ||||||||||||
Review Assigned To | caristu | |||||||||||
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 | 0037115: HQL constant parsing causes contention | |||||||||||
Description | With high concurrency contention at JVM level occurs when Hibernate is creating AST tree for queries at at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:187) at org.hibernate.util.ReflectHelper.getConstantValue(ReflectHelper.java:266) This is caused because HQL allows to include Java constant values, to determine whether a token is or not a constant it performs a classForName whenever it includes a dot, which finally reaches a synchronized block causing this contention. More info here [1]. This is a Hibernate issue HHH-4959 that's fixed starting from 5.2.6 and HHH-11377 (5.2.7). --- [1] https://vladmihalcea.com/2016/12/14/the-performance-penalty-of-class-forname-when-parsing-jpql-and-criteria-queries/ [^] | |||||||||||
Steps To Reproduce | Execute attached test case profiling monitor locks -Check there is huge contention at: java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1200) - waiting to lock <334e3ea4> (a java.lang.Object) owned by "ajp-nio-8009-exec-46" t@125 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167) at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:187) at org.hibernate.util.ReflectHelper.getConstantValue(ReflectHelper.java:266) at org.hibernate.hql.ast.QueryTranslatorImpl$JavaConstantConverter.handleDotStructure(QueryTranslatorImpl.java:599) at org.hibernate.hql.ast.QueryTranslatorImpl$JavaConstantConverter.visit(QueryTranslatorImpl.java:594) at org.hibernate.hql.ast.util.NodeTraverser.visitDepthFirst(NodeTraverser.java:78) at org.hibernate.hql.ast.util.NodeTraverser.traverseDepthFirst(NodeTraverser.java:66) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:280) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:182) - locked <56ccf607> (a org.hibernate.hql.ast.QueryTranslatorImpl) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124) at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156) at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135) at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770) | |||||||||||
Proposed Solution | Backport issues HHH-4959[1][2] and its related HHH-11377[3][4]. Consider bakporting only changes to ReflectHelper.java so that this is enforced and cannot be configured so the complexity of the backport is significantly reduced. Note this would limit usage of Java constants in HQL to only those that conform "valid" Java constant convention (basically package name in lower case, Java class starting by a capital letter and constant field name all upper case: [a-z\\d]+\\.([A-Z]{1}[a-z\\d]+)+\\$?([A-Z]{1}[a-z\\d]+)*\\.[A-Z_\\$]+ --- [1] https://hibernate.atlassian.net/browse/HHH-4959 [^] [2] https://github.com/hibernate/hibernate-orm/commit/0bd7b8 [^] [3] https://hibernate.atlassian.net/browse/HHH-11377 [^] [4] https://github.com/hibernate/hibernate-orm/commit/491d7341 [^] | |||||||||||
Additional Information | ||||||||||||
Tags | Performance | |||||||||||
Relationships |
| |||||||||||
Attached Files | QueryConstantContention.java (2,305) 2017-10-27 15:15 https://issues.openbravo.com/file_download.php?file_id=11243&type=bug Selection_226.png (69,563) 2017-10-27 15:15 https://issues.openbravo.com/file_download.php?file_id=11244&type=bug Selection_227.png (23,962) 2017-10-27 15:16 https://issues.openbravo.com/file_download.php?file_id=11245&type=bug | |||||||||||
Issue History | ||||||||||||
Date Modified | Username | Field | Change | |||||||||
2017-10-19 13:11 | alostale | New Issue | ||||||||||
2017-10-19 13:11 | alostale | Assigned To | => platform | |||||||||
2017-10-19 13:11 | alostale | Modules | => Core | |||||||||
2017-10-19 13:11 | alostale | Triggers an Emergency Pack | => No | |||||||||
2017-10-19 13:12 | alostale | Description Updated | bug_revision_view_page.php?rev_id=16143#r16143 | |||||||||
2017-10-19 13:12 | alostale | Steps to Reproduce Updated | bug_revision_view_page.php?rev_id=16145#r16145 | |||||||||
2017-10-19 13:12 | alostale | Relationship added | related to 0037064 | |||||||||
2017-10-19 13:12 | alostale | Status | new => acknowledged | |||||||||
2017-10-19 14:07 | alostale | Description Updated | bug_revision_view_page.php?rev_id=16146#r16146 | |||||||||
2017-10-19 14:09 | alostale | Description Updated | bug_revision_view_page.php?rev_id=16147#r16147 | |||||||||
2017-10-19 14:12 | alostale | Description Updated | bug_revision_view_page.php?rev_id=16148#r16148 | |||||||||
2017-10-19 14:13 | alostale | Description Updated | bug_revision_view_page.php?rev_id=16149#r16149 | |||||||||
2017-10-27 13:18 | alostale | Tag Attached: Performance | ||||||||||
2017-10-27 15:14 | alostale | Steps to Reproduce Updated | bug_revision_view_page.php?rev_id=16197#r16197 | |||||||||
2017-10-27 15:15 | alostale | File Added: QueryConstantContention.java | ||||||||||
2017-10-27 15:15 | alostale | File Added: Selection_226.png | ||||||||||
2017-10-27 15:16 | alostale | File Added: Selection_227.png | ||||||||||
2017-11-13 13:09 | hgbot | Checkin | ||||||||||
2017-11-13 13:09 | hgbot | Note Added: 0100480 | ||||||||||
2017-11-13 13:09 | hgbot | Status | acknowledged => resolved | |||||||||
2017-11-13 13:09 | hgbot | Resolution | open => fixed | |||||||||
2017-11-13 13:09 | hgbot | Fixed in SCM revision | => http://code.openbravo.com/erp/devel/pi/rev/ea74193b74fa03750c0d26bcb2da2a1103079969 [^] | |||||||||
2017-11-13 13:10 | alostale | Assigned To | platform => alostale | |||||||||
2017-11-13 13:11 | alostale | Review Assigned To | => caristu | |||||||||
2017-11-20 12:43 | caristu | Note Added: 0100619 | ||||||||||
2017-11-20 12:43 | caristu | Status | resolved => closed | |||||||||
2017-11-20 12:43 | caristu | Fixed in Version | => 3.0PR18Q1 |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|