Bug 1116345 - [GSS] (6.3.1) HttpManagementService-threads consumes high cpu on org.jboss.as.jpa.hibernate4.management.QueryName.displayable()
Summary: [GSS] (6.3.1) HttpManagementService-threads consumes high cpu on org.jboss.as...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: JPA
Version: 6.2.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: CR1
: EAP 6.3.1
Assignee: Scott Marlow
QA Contact: Martin Simka
Russell Dickenson
URL:
Whiteboard:
Depends On: 1131711
Blocks: eap631-blockers, eap631-payload, eap63-cp01-blockers
TreeView+ depends on / blocked
 
Reported: 2014-07-04 09:28 UTC by Masafumi Miura
Modified: 2018-12-09 18:07 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1131711 (view as bug list)
Environment:
Last Closed: 2014-10-13 18:39:21 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1132091 0 unspecified CLOSED High CPU usage in hibernate thread (java.util.regex.Pattern$Start.match) 2021-02-22 00:41:40 UTC
Red Hat Issue Tracker JIPI-32 0 Major Closed org.jboss.as.jpa.hibernate4.management.QueryName.displayable() consumes high amount of cpu 2018-01-23 06:08:59 UTC
Red Hat Knowledge Base (Solution) 1120463 0 None None None Never

Internal Links: 1128614 1132091

Description Masafumi Miura 2014-07-04 09:28:34 UTC
Description of problem:

HttpManagementService-threads consumes high cpu on "org.jboss.as.jpa.hibernate4.management.QueryName.displayable()". Thread dump looks like:


~~~
"HttpManagementService-threads - 4223" prio=10 tid=0x00007f1d040f8800 nid=0x7596 runnable [0x00007f1ca5b03000]
   java.lang.Thread.State: RUNNABLE
	at java.util.regex.Pattern$Start.match(Pattern.java:3408)
	at java.util.regex.Matcher.search(Matcher.java:1199)
	at java.util.regex.Matcher.find(Matcher.java:592)
	at java.util.regex.Matcher.replaceAll(Matcher.java:907)
	at java.lang.String.replace(String.java:2180)
	at org.jboss.as.jpa.hibernate4.management.QueryName.displayable(QueryName.java:191)
	at org.jboss.as.jpa.hibernate4.management.QueryName.<init>(QueryName.java:120)
	at org.jboss.as.jpa.hibernate4.management.QueryName.queryName(QueryName.java:110)
	at org.jboss.as.jpa.hibernate4.management.HibernateStatisticsResource.getQueryNames(HibernateStatisticsResource.java:345)
	at org.jboss.as.jpa.hibernate4.management.HibernateStatisticsResource.hasQuery(HibernateStatisticsResource.java:332)
	at org.jboss.as.jpa.hibernate4.management.HibernateStatisticsResource.getChild(HibernateStatisticsResource.java:96)
	at org.jboss.as.controller.OperationContextImpl.getAuthorizationResource(OperationContextImpl.java:1169)
	at org.jboss.as.controller.OperationContextImpl.getBasicAuthorizationResponse(OperationContextImpl.java:1126)
	at org.jboss.as.controller.OperationContextImpl.authorize(OperationContextImpl.java:1049)
	at org.jboss.as.controller.OperationContextImpl.authorize(OperationContextImpl.java:845)
	at org.jboss.as.controller.operations.global.ReadResourceHandler.doExecuteInternal(ReadResourceHandler.java:265)
	at org.jboss.as.controller.operations.global.ReadResourceHandler.doExecute(ReadResourceHandler.java:142)
	at org.jboss.as.controller.operations.global.GlobalOperationHandlers$AbstractMultiTargetHandler.execute(GlobalOperationHandlers.java:249)
	at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:601)
	at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:479)
	at org.jboss.as.controller.AbstractOperationContext.completeStepInternal(AbstractOperationContext.java:283)
	at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:278)
	at org.jboss.as.controller.ModelControllerImpl.internalExecute(ModelControllerImpl.java:231)
	at org.jboss.as.controller.ModelControllerImpl.execute(ModelControllerImpl.java:137)
	at org.jboss.as.controller.ModelControllerImpl$3.execute(ModelControllerImpl.java:437)
	at org.jboss.as.controller.ModelControllerImpl$3.execute(ModelControllerImpl.java:427)
	at org.jboss.as.domain.http.server.DomainApiHandler.processRequest(DomainApiHandler.java:325)
	at org.jboss.as.domain.http.server.DomainApiHandler.doHandle(DomainApiHandler.java:229)
	at org.jboss.as.domain.http.server.DomainApiHandler.handle(DomainApiHandler.java:236)
	at org.jboss.as.domain.http.server.security.SubjectAssociationHandler$1.run(SubjectAssociationHandler.java:69)
	at org.jboss.as.domain.http.server.security.SubjectAssociationHandler$1.run(SubjectAssociationHandler.java:65)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:415)
	at org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:94)
	at org.jboss.as.domain.http.server.security.SubjectAssociationHandler.handleRequest(SubjectAssociationHandler.java:65)
	at org.jboss.as.domain.http.server.security.SubjectAssociationHandler.handle(SubjectAssociationHandler.java:59)
	at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:78)
	at org.jboss.sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:69)
	at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:81)
	at org.jboss.sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:710)
	at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:78)
	at org.jboss.as.domain.http.server.RealmReadinessFilter.doFilter(RealmReadinessFilter.java:47)
	at org.jboss.as.domain.http.server.DmrFailureReadinessFilter.doFilter(DmrFailureReadinessFilter.java:45)
	at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:81)
	at org.jboss.sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:682)
	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:744)
	at org.jboss.threads.JBossThread.run(JBossThread.java:122)
~~~


It appears that many "String.replace()" are called in order to escape SQL query. 


* jpa/hibernate4/src/main/java/org/jboss/as/jpa/hibernate4/management/QueryName.java

~~~
154     /**
155      * transform a Hibernate HQL query into something that can be displayed/used for management operations
156      *
157      * @param query
158      * @return
159      */
160     private String displayable(String query) {
161         if (query == null ||
162             query.length() == 0) {
163             return query;
164         }
165         // handle two character transforms first
166         query = query.replace(SQL_NE, NOT_EQUAL__);
167         query = query.replace(NE_BANG, BANG_NOT_EQUAL__);
168         query = query.replace(NE_HAT, HAT_NOT_EQUAL__);
169         query = query.replace(LE, LESS_THAN_EQUAL__);
170         query = query.replace(GE, GREATER_THAN_EQUAL__);
171         query = query.replace(CONCAT, CONCAT__);
172         query = query.replace(LT, LESS_THAN__);
173         query = query.replace(EQ, EQUAL__);
174         query = query.replace(GT, GREATER__);
175         query = query.replace(OPEN, LEFT_PAREN__);
176         query = query.replace(CLOSE, RIGHT_PAREN__);
177         query = query.replace(OPEN_BRACKET, LEFT_BRACKET__);
178         query = query.replace(CLOSE_BRACKET, RIGHT_BRACKET__);
179         query = query.replace(PLUS, PLUS__);
180         query = query.replace(MINUS, MINUS__);
181         query = query.replace(STAR, STAR__);
182         query = query.replace(DIV, DIVIDE__);
183         query = query.replace(MOD, MODULUS__);
184         query = query.replace(COLON, COLON__);
185         query = query.replace(PARAM, PARAM__);
186         query = query.replace(COMMA, COMMA__);
187         query = query.replace(SPACE, SPACE__);
188         query = query.replace(TAB, TAB__);
189         query = query.replace(NEWLINE, NEWLINE__);
190         query = query.replace(LINEFEED, LINEFEED__);
191         query = query.replace(QUOTE, QUOTE__);
192         query = query.replace(DQUOTE, DQUOTE__);
193         query = query.replace(TICK, TICK__);
194         query = query.replace(OPEN_BRACE, OPEN_BRACE__);
195         query = query.replace(CLOSE_BRACE, CLOSE_BRACE__);
196         query = query.replace(HAT, HAT__);
197         query = query.replace(AMPERSAND, AMPERSAND__);
198         return query;
199     }
~~~


The above logic caused high cpu issue and the customer faced JBoss slowdown.

Comment 20 Jan Martiska 2014-09-02 07:42:53 UTC
Verified in EAP 6.3.1.CR1.


Note You need to log in before you can comment on or make changes to this bug.