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); + } } }