Fix Inconsistencies by restarting AEM when SegmentNotFound Issue is reported in AEM 6.3

Issue

A SegmentNotFoundException is observed in the log files. Restarting AEM makes the error go away for one day (or longer).

For example:

29.09.2017 05:40:27.031 *ERROR* [10.40.228.155 [1506663627021] GET /services/createvaultpackage HTTP/1.1] org.apache.jackrabbit.oak.segment.SegmentNotFoundExceptionListener Segment not found: 6c3c7910-6501-4c0a-af5d-6972006c6145. SegmentId age=654602216ms,segment-generation=17
org.apache.jackrabbit.oak.segment.SegmentNotFoundException: Segment 6c3c7910-6501-4c0a-af5d-6972006c6145 not found
at org.apache.jackrabbit.oak.segment.file.FileStore$8.call(FileStore.java:602)
...
at org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager.internalGetNodeType(ReadOnlyNodeTypeManager.java:409)
at org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager.getNodeType(ReadOnlyNodeTypeManager.java:147)
at org.apache.jackrabbit.vault.packaging.impl.JcrPackageManagerImpl.initNodeTypes(JcrPackageManagerImpl.java:737)
at org.apache.jackrabbit.vault.packaging.impl.JcrPackageManagerImpl.(JcrPackageManagerImpl.java:109)
at org.apache.jackrabbit.vault.packaging.PackagingService.getPackageManager(PackagingService.java:49)
at customcode.VaultPackageFromSearchServlet.doGet(VaultPackageFromSearchServlet.java:172)

Environment

AEM 6.3 and later versions with Online Compaction enabled

Cause

It can be caused due to long running JCR sessions along with online compaction.

Resolution

Avoid keeping JCR sessions open for a long time.  To resolve the issue:

  1. Close the session and open a new one when required.
  2. Or periodically call session.refresh(true).

See this article for more details on the topic of long running sessions being an anti-pattern in AEM 6.x.

 Adobe

Get help faster and easier

New user?

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online