Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Unclosed session detected.

Avatar

Level 1

I am investigating a memory leak on one of our production servers. The leak is requiring a restart twice per week. I followed the instructions to analyze unclosed sessions from this page and I am now seeing several logs warning about unclosed sessions. I've scoured the code, and I can only find one or two instances where sessions are left unclosed. I'm not sure if that would cause a leak of this extent. In addition, the log messages I'm seeing don't mention any custom code. Could this be an AEM issue? Has anyone ever run into this type of issue before? Any suggestions as to the next steps I should take?

Example log:

03.01.2018 19:54:26.124 *WARN* [Finalizer] org.apache.jackrabbit.core.SessionImpl Unclosed session detected. The session was opened here: java.lang.Exception: Stack Trace

at org.apache.jackrabbit.core.SessionImpl.<init>(SessionImpl.java:222)

at org.apache.jackrabbit.core.XASessionImpl.<init>(XASessionImpl.java:117)

at com.day.crx.core.CRXSessionImpl.<init>(CRXSessionImpl.java:69)

at com.day.crx.core.CRXRepositoryImpl.createSessionInstance(CRXRepositoryImpl.java:935)

at org.apache.jackrabbit.core.RepositoryImpl.createSession(RepositoryImpl.java:959)

at org.apache.jackrabbit.core.SessionFactory.createAdminSession(SessionFactory.java:42)

at com.day.crx.sling.server.impl.SlingRepositoryWrapper.loginAdministrative(SlingRepositoryWrapper.java:76)

at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory.getResourceProviderInternal(JcrResourceProviderFactory.java:136)

at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory.getAdministrativeResourceProvider(JcrResourceProviderFactory.java:115)

at org.apache.sling.resourceresolver.impl.tree.ResourceProviderFactoryHandler.login(ResourceProviderFactoryHandler.java:162)

at org.apache.sling.resourceresolver.impl.tree.RootResourceProviderEntry.loginToRequiredFactories(RootResourceProviderEntry.java:95)

at org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl.getResourceResolverInternal(ResourceResolverFactoryImpl.java:98)

at org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl.getAdministrativeResourceResolver(ResourceResolverFactoryImpl.java:72)

at org.apache.sling.resourceresolver.impl.helper.ResourceResolverContext.getResourceTypeResourceResolver(ResourceResolverContext.java:192)

at org.apache.sling.resourceresolver.impl.helper.ResourceResolverContext.getParentResourceType(ResourceResolverContext.java:216)

at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getParentResourceType(ResourceResolverImpl.java:1136)

at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getParentResourceType(ResourceResolverImpl.java:1126)

at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.isResourceType(ResourceResolverImpl.java:1151)

at org.apache.sling.api.resource.AbstractResource.isResourceType(AbstractResource.java:115)

at com.day.cq.dam.scene7.impl.listener.Scene7AssetActivationListener.searchViewerWidgets(Scene7AssetActivationListener.java:304)

at com.day.cq.dam.scene7.impl.listener.Scene7AssetActivationListener.activatePageReferences(Scene7AssetActivationListener.java:208)

at com.day.cq.dam.scene7.impl.listener.Scene7AssetActivationListener.process(Scene7AssetActivationListener.java:161)

at org.apache.sling.event.jobs.JobUtil$1.run(JobUtil.java:365)

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:745)

We are running AEM 5.6.1. I would really appreciate any help.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

That's product code, and I would assume that there is a fix available for it. Please check with the Adobe support.

On the other hand: 5.6.1 will run out of extended support soon, and I would recommend to do an upgrade to a newer version.

Jörg

View solution in original post

7 Replies

Avatar

Level 10

You state "'ve scoured the code, and I can only find one or two instances where sessions are left unclosed"

Its best practice to ensure that all JCR Sessions are closed once you are done with them.

Avatar

Level 1

Hi smacdonald2008 , thanks for the reply.

I will be closing the sessions I found, but as I mentioned, it doesn't seem like two instances of unclosed sessions in the code would be causing a memory leak of this extent. And the classes that I found the open sessions in are not mentioned in any of the log statements that I'm seeing. In fact, there are no custom classes at all mentioned in the log statements, which is what is really confusing me. Shouldn't the log statements to mention custom classes if that is where the problem resides? Or are the log statements indicating that there is a memory leak in the OOTB classes?

Avatar

Level 6

My thought:

Yes I saw similar case before.There were some OOTB stack trace for brand new instance in 5.6.1. we monitored it for a day or two and reported it Adobe. We basically have to compare your instance before and after you deploy your code package.

Avatar

Level 1

mjb54261515 so you would recommend setting up a new instance without deploying custom code, and testing on the Geometrixx site? And I'm assuming this could just be done on a local instance?

Avatar

Level 6

Yes on local instance will work, pls install all necessary service and fix packs thats used in prod servers.

Avatar

Correct answer by
Employee Advisor

That's product code, and I would assume that there is a fix available for it. Please check with the Adobe support.

On the other hand: 5.6.1 will run out of extended support soon, and I would recommend to do an upgrade to a newer version.

Jörg

Avatar

Administrator

If the code that creates the session is AEM, Sling or Oak product code then contact AEM Customer Care.

Otherwise, if it is in custom code, the solution is to logout of the Session or close the ResourceResolver when you're done using it.

Example of session being opened and closed:

Session session = null; try {   session = repository.getService("readService",null);   // use session } finally {   if(session != null && session.isLive()) {     session.logout();   } }

Example ResourceResolver being opened and closed:

ResourceResolver resolver = null; try {   resolver = resourceFactory.getServiceResourceResolver(paramMap);    // use resolver } finally {   if(resolver != null && resolver.isLive()){     resolver.close();   } }


Kautuk Sahni