You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by md...@apache.org on 2016/10/06 09:03:28 UTC
svn commit: r1763532 -
/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
Author: mduerig
Date: Thu Oct 6 09:03:27 2016
New Revision: 1763532
URL: http://svn.apache.org/viewvc?rev=1763532&view=rev
Log:
OAK-4685: Avoid concurrent calls to FileStore.cleanup() and FileStore.compact()
Execute garbage collection on the scheduler
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=1763532&r1=1763531&r2=1763532&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 Oct 6 09:03:27 2016
@@ -185,10 +185,9 @@ public class FileStore implements Segmen
private final PeriodicOperation flushOperation;
/**
- * The background compaction thread. Compacts the TarMK contents whenever
- * triggered by the {@link #gc()} method.
+ * Scheduler for running compaction and cleanup in the background
*/
- private final TriggeredOperation compactionOperation;
+ private final Scheduler gcScheduler = new Scheduler("GC Scheduler");
/**
* This background thread periodically asks the {@code SegmentGCOptions}
@@ -359,19 +358,6 @@ public class FileStore implements Segmen
});
- compactionOperation = new TriggeredOperation(format("TarMK compaction thread [%s]", directory), new Runnable() {
-
- @Override
- public void run() {
- try {
- maybeCompact(true);
- } catch (IOException e) {
- log.error("Error running compaction", e);
- }
- }
-
- });
-
diskSpaceOperation = new PeriodicOperation(format("TarMK disk space check [%s]", directory), 1, MINUTES, new Runnable() {
@Override
@@ -1179,20 +1165,12 @@ public class FileStore implements Segmen
// Flag the store as shutting / shut down
shutdown = true;
+ gcScheduler.close();
+
// avoid deadlocks by closing (and joining) the background
// threads before acquiring the synchronization lock
try {
- if (compactionOperation.stop(5, SECONDS)) {
- log.debug("The compaction background thread was successfully shut down");
- } else {
- log.warn("The compaction background thread takes too long to shutdown");
- }
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
-
- try {
if (flushOperation.stop(5, SECONDS)) {
log.debug("The flush background thread was successfully shut down");
} else {
@@ -1464,7 +1442,16 @@ public class FileStore implements Segmen
* Trigger a garbage collection cycle
*/
public void gc() {
- compactionOperation.trigger();
+ gcScheduler.execute(format("TarMK compaction thread [%s]", directory), new Runnable() {
+ @Override
+ public void run() {
+ try {
+ maybeCompact(true);
+ } catch (IOException e) {
+ log.error("Error running compaction", e);
+ }
+ }
+ });
}
public Map<String, Set<UUID>> getTarReaderIndex() {