Author: frm
Date: Thu Nov 10 10:59:08 2016
New Revision: 1769081
URL: http://svn.apache.org/viewvc?rev=1769081&view=rev
Log:
OAK-5093 - Return the number of the new generation if compaction fails
Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java?rev=1769081&r1=1769080&r2=1769081&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
Thu Nov 10 10:59:08 2016
@@ -818,13 +818,13 @@ public class FileStore extends AbstractF
}
synchronized int compact() throws IOException {
+ final int newGeneration = getGcGeneration() + 1;
try {
Stopwatch watch = Stopwatch.createStarted();
gcListener.info("TarMK GC #{}: compaction started, gc
options={}", GC_COUNT, gcOptions);
SegmentNodeState before = getHead();
Supplier<Boolean> cancel = new
CancelCompactionSupplier(FileStore.this);
- final int newGeneration = getGcGeneration() + 1;
SegmentWriter writer = segmentWriterBuilder("c")
.with(cacheManager)
.withGeneration(newGeneration)
@@ -834,7 +834,7 @@ public class FileStore extends AbstractF
SegmentNodeState after = compact(before, writer, cancel);
if (after == null) {
gcListener.info("TarMK GC #{}: compaction cancelled: {}.",
GC_COUNT, cancel);
- return 0;
+ return -newGeneration;
}
gcListener.info("TarMK GC #{}: compacted {} to {}",
@@ -855,7 +855,7 @@ public class FileStore extends AbstractF
after = compact(head, writer, cancel);
if (after == null) {
gcListener.info("TarMK GC #{}: compaction cancelled:
{}.", GC_COUNT, cancel);
- return 0;
+ return -newGeneration;
}
gcListener.info("TarMK GC #{}: compacted {} against {} to
{}",
@@ -899,10 +899,10 @@ public class FileStore extends AbstractF
} catch (InterruptedException e) {
gcListener.error("TarMK GC #" + GC_COUNT + ": compaction
interrupted", e);
currentThread().interrupt();
- return 0;
+ return -newGeneration;
} catch (Exception e) {
gcListener.error("TarMK GC #" + GC_COUNT + ": compaction
encountered an error", e);
- return 0;
+ return -newGeneration;
}
}