From 6c34f29ac20fcee569514a401d74256e579928c4 Mon Sep 17 00:00:00 2001 From: Keith Turner Date: Thu, 8 Nov 2018 15:34:42 -0500 Subject: [PATCH] Only requeue compaction when there was activity --- .../tserver/tablet/CompactionRunner.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactionRunner.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactionRunner.java index 8fab78c4d65..8de7a9e9b30 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactionRunner.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactionRunner.java @@ -41,12 +41,18 @@ public void run() { return; } - tablet.majorCompact(reason, queued); + CompactionStats stats = tablet.majorCompact(reason, queued); - // if there is more work to be done, queue another major compaction - synchronized (tablet) { - if (reason == MajorCompactionReason.NORMAL && tablet.needsMajorCompaction(reason)) - tablet.initiateMajorCompaction(reason); + // Some compaction strategies may always return true for shouldCompact() because they need to + // make blocking calls to gather information. Without the following check these strategies would + // endlessly requeue. So only check if a subsequent compaction is needed if the previous + // compaction actually did something. + if (stats != null && stats.getEntriesRead() > 0) { + // if there is more work to be done, queue another major compaction + synchronized (tablet) { + if (reason == MajorCompactionReason.NORMAL && tablet.needsMajorCompaction(reason)) + tablet.initiateMajorCompaction(reason); + } } }