diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplit.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplit.java index 441b18b3302f..158b86fd61bc 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplit.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplit.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.Optional; @@ -444,14 +445,24 @@ public int getCompactionQueueSize() { } public int getLargeCompactionQueueSize() { + removeFilesFromFilesCompacting(longCompactions); return longCompactions.getQueue().size(); } public int getSmallCompactionQueueSize() { + removeFilesFromFilesCompacting(shortCompactions); return shortCompactions.getQueue().size(); } + private void removeFilesFromFilesCompacting(ThreadPoolExecutor compactor) { + for (Runnable runnable : compactor.getQueue()) { + CompactionRunner runner = (CompactionRunner) runnable; + Collection files = runner.compaction.getRequest().getFiles(); + runner.store.removeFromCompactingFiles(files); + } + } + public int getSplitQueueSize() { return splits.getQueue().size(); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java index 45b17bb32ad1..648f6fd549e5 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java @@ -1953,6 +1953,16 @@ private void addToCompactingFiles(Collection filesToAdd) { Collections.sort(filesCompacting, storeEngine.getStoreFileManager().getStoreFileComparator()); } + /** + * remove the files from compacting files. This usually happens when we clear compaction queues. + */ + public void removeFromCompactingFiles(Collection filesToRemove) { + synchronized (filesCompacting) { + filesCompacting.removeAll(filesToRemove); + Collections.sort(filesCompacting, storeEngine.getStoreFileManager().getStoreFileComparator()); + } + } + private void removeUnneededFiles() throws IOException { if (!conf.getBoolean("hbase.store.delete.expired.storefile", true)) { return;