[ 
https://issues.apache.org/jira/browse/OAK-7132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16323836#comment-16323836
 ] 

Michael Dürig commented on OAK-7132:
------------------------------------

The problem is with the cleanup predicate after a successful compaction: 

{code}
  return isOld(generation) && !sameCompactedTail(generation);
{code}

After a full compaction this predicate considers segments from the previous 
tail reclaimable violating the minimal number of retained generations. With the 
default of 2 retained generations we get segments of the following generations 
after two tail compactions followed by one full compaction:

{noformat}
GCGeneration{generation=0,fullGeneration=0,isCompacted=true} 
GCGeneration{generation=1,fullGeneration=0,isCompacted=true}  
GCGeneration{generation=2,fullGeneration=2,isCompacted=true}
{noformat}

At this point the predicate retains segments from the last two generations (1 
and 2) as they are not old. But it will not retain segments from the first 
generation (0) as these are old and not from the same tail (the full generation 
numbers differ). However, this makes the previous generation inconsistent as it 
removes the initial bits of its tail (including its base, namely the segments 
created by the previous full compaction). The [respective unit 
test|http://svn.apache.org/viewvc?rev=1820734&view=rev] demonstrates the 
problem by traversing the head state from just before running full compaction. 

To fix this we need to use a different reclamation predicate after a full 
compaction: 

{code}
  return isOldFull(generation) || (isOld(generation) && 
!generation.isCompacted());
{code}

This predicate only considers a segment reclaimable if it is either from an old 
full generation or not part of the previous tail (i.e. no compaction flag set) 
while at the same time old enough. See 
https://github.com/mduerig/jackrabbit-oak/commits/OAK-7132 for a patch 
implementing this new predicate. 





> SNFE after full compaction
> --------------------------
>
>                 Key: OAK-7132
>                 URL: https://issues.apache.org/jira/browse/OAK-7132
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: segment-tar
>    Affects Versions: 1.8.0
>            Reporter: Michael Dürig
>            Assignee: Michael Dürig
>            Priority: Blocker
>              Labels: compaction
>             Fix For: 1.9.0, 1.10, 1.8.1
>
>
> In some cases we observed a {{SNFE}} right after a the cleanup following a 
> full compaction:
> {noformat}
> 31.12.2017 04:25:19.816 *ERROR* [pool-17-thread-22] 
> org.apache.jackrabbit.oak.segment.SegmentNotFoundExceptionListener Segment 
> not found: a82a99a3-f1e9-49b7-a1e0-55e7fec80c41. SegmentId 
> age=609487478ms,segment-generation=GCGeneration{generation=4,fullGeneration=2,isCompacted=true}
> org.apache.jackrabbit.oak.segment.SegmentNotFoundException: Segment 
> a82a99a3-f1e9-49b7-a1e0-55e7fec80c41 not found
>         at 
> org.apache.jackrabbit.oak.segment.file.AbstractFileStore.readSegmentUncached(AbstractFileStore.java:276)
>         at 
> org.apache.jackrabbit.oak.segment.file.FileStore.lambda$readSegment$5(FileStore.java:478)
>         at 
> org.apache.jackrabbit.oak.segment.SegmentCache.lambda$getSegment$0(SegmentCache.java:116)
>         at 
> com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4724)
>         at 
> com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3522)
>         at 
> com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2315)
>         at 
> com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2278)
>         at 
> com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2193)
>         at com.google.common.cache.LocalCache.get(LocalCache.java:3932)
>         at 
> com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4721)
>         at 
> org.apache.jackrabbit.oak.segment.SegmentCache.getSegment(SegmentCache.java:113)
>         at 
> org.apache.jackrabbit.oak.segment.file.FileStore.readSegment(FileStore.java:478)
>         at 
> org.apache.jackrabbit.oak.segment.SegmentId.getSegment(SegmentId.java:154)
>         at 
> org.apache.jackrabbit.oak.segment.CachingSegmentReader$1.apply(CachingSegmentReader.java:94)
>         at 
> org.apache.jackrabbit.oak.segment.CachingSegmentReader$1.apply(CachingSegmentReader.java:90)
>         at 
> org.apache.jackrabbit.oak.segment.ReaderCache.get(ReaderCache.java:118)
>         at 
> org.apache.jackrabbit.oak.segment.CachingSegmentReader.readString(CachingSegmentReader.java:90)
>         at 
> org.apache.jackrabbit.oak.segment.MapRecord.getEntry(MapRecord.java:220)
>         at 
> org.apache.jackrabbit.oak.segment.MapRecord.getEntry(MapRecord.java:173)
>         at 
> org.apache.jackrabbit.oak.segment.SegmentNodeState.getChildNode(SegmentNodeState.java:423)
>         at 
> org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder.<init>(MemoryNodeBuilder.java:143)
>         at 
> org.apache.jackrabbit.oak.segment.SegmentNodeBuilder.<init>(SegmentNodeBuilder.java:93)
>         at 
> org.apache.jackrabbit.oak.segment.SegmentNodeBuilder.createChildBuilder(SegmentNodeBuilder.java:148)
>         at 
> org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder.getChildNode(MemoryNodeBuilder.java:331)
>         at 
> org.apache.jackrabbit.oak.core.SecureNodeBuilder.<init>(SecureNodeBuilder.java:112)
>         at 
> org.apache.jackrabbit.oak.core.SecureNodeBuilder.getChildNode(SecureNodeBuilder.java:329)
>         at 
> org.apache.jackrabbit.oak.core.MutableTree.getTree(MutableTree.java:290)
>         at 
> org.apache.jackrabbit.oak.core.MutableRoot.getTree(MutableRoot.java:220)
>         at 
> org.apache.jackrabbit.oak.core.MutableRoot.getTree(MutableRoot.java:69)
>         at 
> org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.getItem(SessionDelegate.java:442)
>         at 
> org.apache.jackrabbit.oak.jcr.session.SessionImpl.getItemInternal(SessionImpl.java:167)
>         at 
> org.apache.jackrabbit.oak.jcr.session.SessionImpl.access$400(SessionImpl.java:82)
>         at 
> org.apache.jackrabbit.oak.jcr.session.SessionImpl$3.performNullable(SessionImpl.java:229)
>         at 
> org.apache.jackrabbit.oak.jcr.session.SessionImpl$3.performNullable(SessionImpl.java:226)
>         at 
> org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.performNullable(SessionDelegate.java:243)
>         at 
> org.apache.jackrabbit.oak.jcr.session.SessionImpl.getItemOrNull(SessionImpl.java:226)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to