Session scoped JSF beans accumulate in WebInjectionContainer when a distributable session cache is used
Environment
- JBoss Enterprise Application Platform (EAP) 7.x
Issue
- When our application has the
<distributable/>tag in its WEB-INF/web.xml, we see heap growth from JSF session scoped beans accumulating in the WebInjectionContainer:
Class Name | Ref. Objects | Shallow Heap | Ref. Shallow Heap | Retained Heap
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
service org.wildfly.extension.undertow.deployment.UndertowDeploymentService @ 0x50f329230 | 125,147 | 40 | 9,010,584 | 40
'- webInjectionContainer org.jboss.as.web.common.WebInjectionContainer @ 0x50f329298 | 125,147 | 24 | 9,010,584 | 3,401,632,128
'- instanceMap org.jboss.as.web.common.ConcurrentReferenceHashMap @ 0x50f3292b0 | 125,147 | 48 | 9,010,584 | 3,401,632,104
'- segments org.jboss.as.web.common.ConcurrentReferenceHashMap$Segment[2] @ 0x50f3292e0 | 125,147 | 24 | 9,010,584 | 3,401,632,056
|- [0] org.jboss.as.web.common.ConcurrentReferenceHashMap$Segment @ 0x50f34b958 | 62,788 | 56 | 4,520,736 | 1,502,618,200
| '- table org.jboss.as.web.common.ConcurrentReferenceHashMap$HashEntry[131072] @ 0x591400000| 62,788 | 524,304 | 4,520,736 | 1,502,618,032
| |- [58249] org.jboss.as.web.common.ConcurrentReferenceHashMap$HashEntry @ 0x641530970 | 5 | 32 | 360 | 8,144
| | | |- keyRef com.redhat.BeanInstance @ 0x641530990 | 1 | 72 | 72 | 1,328
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Session attribute listeners are invoked upon session destruction with a non-distributable session manager, but they are no longer invoked in this case when our app is set for
<distributable/>
Resolution
- Upgrade to 7.2.9 or 7.3.2 for some relevant fixes and to 7.3.8+ or 7.4.2+ for remaining fixes related to session timeout events causing a leak if triggered on a cluster member different from the member last serving the session and its requests.
- As a workaround, disable the
<distributable/>flag
Root Cause
- The distributable session manager does not truly remove session attributes upon session destruction while non-distributable session manager does. Thus, JSF session beans are not destroyed since
com.sun.faces.application.WebappLifecycleListeneris not invoked - The JSF bean instances were originally cached separately from the session itself. This could lead to a scenario in a cluster where the session times out on one member and doesn't trigger removal of the JSF bean on another member
Components
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.