Red Hat Bugzilla – Bug 1250140
[scale] - org.jboss.resteasy.spi.ResteasyProviderFactory potential leak
Last modified: 2016-04-19 21:26:59 EDT
Description of problem:
engine runs OOM after 1835 rest actions.
seems like there is class loader leak around:
which runs by 'Worker' Threads and 'org.ovirt.thread.pool'
the use case drives by QE engine that serve many jenkins jobs.
reproduced the bug on top synthetic engine required.
on other hand QE Automation will double check their automation code for risky areas such as (api.disconnect).
link for heap file:
update the bug with further more information ASAP.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. engine with 2GB ram.
2. 734 tests 2.5 times per day till the problem happens (1835 rest actions)
OOM after a while.
Continues Hours Operation
how many connections jenkins handle?
is it connection per test ? or team or one connection for all?
What that heap dump shows is that the server has created 44 instances of the "com.sun.xml.bind.v2.runtime.JAXBContextImpl" class. Instances of this class store all the information required to convert any of the objects used by the RESTAPI to/from XML, and each of them consumes approx 22 MiB, for a total of approx 115 MiB.
All these "JAXBContextImpl" instances are created by the Resteasy builtin JAXB provider "org.jboss.resteasy.plugins.providers.jaxb.JAXBContextWrapper" and stored in a cache indexed by type of object:
DataCenter -> First instance
Cluster -> Second instance
VM -> Third instance
In general these instances may contain different information, but in our case all of them are identical, so one would be enough, but this isn't how the builtin JAXB provider works.
If we want to improve this we need to backport the following change, which introduces a custom message body writer that creates only one JAXB context implementation:
restapi: JAXB provider
Oved, please set the 3.5.z flag and acks if you want this backported.
Sounds like we should.
I've set flags and target release accordingly.
one per execution
The two backported patches should fix this issue. To verify that the issue is fixed check that the number of instances of the JAXBContextImpl classes doesn't increase when new types of objects are requested via the RESTAPI:
# ps -u ovirt | grep java
22143 ? 00:00:24 java
# su - ovirt -s /bin/sh
$ jmap -histo 22143 | grep 'JAXBContextImpl$'
1057: 4 352 com.sun.xml.bind.v2.runtime.JAXBContextImp
Before the fix the number of instances will increase when new types of objects are requested. After the fix the number of instances (the second column, 4 in the example above) should stay constant.
Sorry, but in which ovirt version was this bug introduced? was it always there?
I can't use "jmap" because I can't install it easily in my production environment.
I think that the bug was always there, but I'm not 100% sure because it depends on the version of JBoss and I didn't check all the versions of JBoss, only WildFly 8.2 and JBoss EAP 6.3.
Note that although it is described as a "leak", it actually isn't, because there is a limit to the number of instances of "JAXBContextImpl" that are created, approx 50, because there are approx 50 types of objects in the RESTAPI. If you send 10 million requests to get VMs, for example, it won't create 10 million instances of "JAXBContextImpl", only 50, at most.
The "jmap" tool is part of the "java-1.7.0-openjdk-devel" package. Installing won't hurt your production environment. But it is strange that you don't have it already, it is installed when the "ovirt-engine" package is installed, at least for oVirt 3.5 and later. Alternatively you may take the "jmap" binary from another machine (with the same version of java-1.7.0-openjdk) and copy it to your production environment, execute, and then remove it.
Verified on top of
rhevm - 126.96.36.199-0.1.el6
JBoss Enterprise Application Platform - Version 6.4.5.GA
having constant instance amount during the load test and after it.