Author: mduerig
Date: Thu Aug 31 09:26:36 2017
New Revision: 1806775
URL: http://svn.apache.org/viewvc?rev=1806775&view=rev
Log:
OAK-6601: SegmentWriteOperation.isOldGeneration() too eager
Refine isOldGeneration predicate to properly take tail and full compacted
segments into account.
Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/DefaultSegmentWriter.java
Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/DefaultSegmentWriter.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/DefaultSegmentWriter.java?rev=1806775&r1=1806774&r2=1806775&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/DefaultSegmentWriter.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/DefaultSegmentWriter.java
Thu Aug 31 09:26:36 2017
@@ -990,7 +990,16 @@ public class DefaultSegmentWriter implem
try {
GCGeneration thatGen = id.getSegmentId().getGcGeneration();
GCGeneration thisGen = writer.getGCGeneration();
- return thatGen.compareWith(thisGen) < 0;
+ if (thatGen.isCompacted()) {
+ // If the segment containing the base state is compacted
it is
+ // only considered old if it is from a earlier full
generation.
+ // Otherwise it is from the same tail and it is safe to
reference.
+ return thatGen.getFullGeneration() <
thisGen.getFullGeneration();
+ } else {
+ // If the segment containing the base state is from a
regular writer
+ // it is considered old as soon as it is from an earlier
generation.
+ return thatGen.compareWith(thisGen) < 0;
+ }
} catch (SegmentNotFoundException snfe) {
// This SNFE means a defer compacted node state is too far
// in the past. It has been gc'ed already and cannot be