[jboss-jira] [JBoss JIRA] (WFLY-13259) Memory leak in Hibernate pending-puts cache when L2 cache is enabled

Sorin Potra (Jira) issues at jboss.org
Wed Mar 25 07:28:36 EDT 2020


    [ https://issues.redhat.com/browse/WFLY-13259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14008424#comment-14008424 ] 

Sorin Potra commented on WFLY-13259:
------------------------------------

I want to bring to your attention another aspect that might help in finding the root cause of this issue. In WildFly 13 (EE7 profile) the leak is less severe. If you run the test client, you will notice that memory usage is high immediately after running the first 3500 transactions. But then, if you leave the client running and wait for a few minutes you will notice that memory usage will decrease significantly. What seems to happen is that in WildFly 13, subsequent transactions do not touch the old pending-puts entries so these will expire after 60s and will be removed by the reaping thread.  So basically in WildFly 13 the leak only affects the transactions from the last few minutes. This makes it less severe but it can still be a problem if a large number of transactions are executed in a short period of time.

If you switch WildFly 13 to EE8 profile (<property name="ee8.preview.mode" value="true"/>) then you will reproduce the issue as in WildFly 19.

> Memory leak in Hibernate pending-puts cache when L2 cache is enabled
> --------------------------------------------------------------------
>
>                 Key: WFLY-13259
>                 URL: https://issues.redhat.com/browse/WFLY-13259
>             Project: WildFly
>          Issue Type: Bug
>          Components: JPA / Hibernate
>    Affects Versions: 18.0.1.Final, 19.0.0.Final
>            Reporter: Sorin Potra
>            Assignee: Scott Marlow
>            Priority: Critical
>         Attachments: PathToGCRoots_strong_refs.PNG, afterOOM.hprof.zip, beforeOOM.hprof.zip, pending-puts-leak.PNG, simple-hibernate-war-client.zip, simple-hibernate-war-client.zip.2020-03-25, simple-hibernate-war.war, simple-hibernate-war.war.2020-03-25, simple-hibernate-war.zip, simple-hibernate-war.zip.2020-03-25
>
>
> Under certain conditions, described below, WildFly / Hibernate can leak memory into the pending-puts cache eventually causing an OutOfMemoryError. Attached you can find a web application and a standalone client that can be used to reproduce the problem. The web app defines two entities: a Parent and a Child. There is a bidirectional one-to-many relationship between the Parent and the Child. JPA L2 cache is enabled (Infinispan is the cache provider).
> Repeatedly executing a transaction that creates a new Child and adds it to the list of children in the Parent will cause the memory usage to increase steadily until OOM is encountered. If the execution of these transactions is stopped before reaching OOM, the memory will be reclaimed after a few minutes of inactivity.
> Attached you can find the following:
> - simple-hibernate-war.war - the web app that can be deployed in WildFly to reproduce the issue.
> - simple-hibernate-war.zip - the source code for the above web app. The servlet that is invoked by the client to create and persist a new Child is com.microfocus.sa.web.AddChildServlet
> - simple-hibernate-war-client.zip - the standalone client that can be used to invoke the AddChildServlet. After unzipping the archive, the client can be run with the following command from the client folder:
>   
>   java -cp bin com.microfocus.sa.client.AddChildClient
>   
> If you need to run the client multiple times, you have to restart WildFly in between the runs, to start from a fresh state (the web app uses the h2 in memory databasewhich is reset at each restart).
> - pending-puts-leak.PNG - a screeshot from Memory Analyzer showing a leaked SessionImpl instance



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jboss-jira mailing list