]
Harald Wellmann commented on WFLY-6376:
---------------------------------------
Looks good now! Tested with a local build of master
(c5a2e962edef196ec849d4e8e44821aec05dc3e5) with your PR 8793 applied locally.
Class loader leak due to Infinispan ExpirationManagerImpl
---------------------------------------------------------
Key: WFLY-6376
URL:
https://issues.jboss.org/browse/WFLY-6376
Project: WildFly
Issue Type: Bug
Components: Clustering, JPA / Hibernate
Affects Versions: 10.0.0.Final
Reporter: Harald Wellmann
Assignee: Paul Ferraro
Priority: Critical
h3. Scenario
Given a WAR containing a persistence unit with second level cache and query cache
enabled, I'm consistently hitting a Metaspace OutOfMemoryError after redeploying the
unchanged application a couple of times.
Analyzing the situation with Eclipse Memory Analyzer, I found one cause to be WFLY-6348,
but even after applying that fix locally, I'm still having a Classloader leak which I
can trace to a thread used by Infinispan referencing an obsolete web app classloader as
context classloader.
Just to rule out that this might be related to WFLY-6283, WFLY-6285, I repeated my
experiments with a local build of WildFly master
(2f11a59aee0dbdd52b65c5c684eafa83c3f418da), with Hibernate locally upgraded to 5.0.9.
I'm still getting a classloader leak with that build.
h3. Analysis
{{org.infinispan.expiration.impl.ExpirationManagerImpl}} uses a
{{LazyInitializingScheduledExecutorService}}. Due to lazy initialization, the
{{ExecutorService}} and the underlying thread pool is not created until my web app is
deployed. Thus, when the {{ExecutorService}} is created, the context class loader is set
to the web app class loader, and this appears to propagate to the threads of the executor
thread pool.
When the application is undeployed, {{ExpirationManagerImpl.stop()}} gets invoked to
cancel any running expiration task. However, the {{ExecutorService}} is not shut down, the
threads remain alive and still keep a reference to the now obsolete context classloader.
h3. Remarks
I'm not sure if this analysis is correct, at least I hope there's a clue for
WildFly and Infinispan experts to identify the real cause.
By the way, it would be helpful if all threads created by Infinispan had meaningful
names, rather than default names like {{pool-5-thread-1}}.