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 1360a20c0f83..5b75d3414f1b 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 @@ -315,11 +315,13 @@ public void switchCompaction(boolean onOrOff) { LOG.info("Re-Initializing compactions because user switched on compactions"); reInitializeCompactionsExecutors(); } - } else { - LOG.info("Interrupting running compactions because user switched off compactions"); - interrupt(); + setCompactionsEnabled(onOrOff); + return; } + setCompactionsEnabled(onOrOff); + LOG.info("Interrupting running compactions because user switched off compactions"); + interrupt(); } private void requestCompactionInternal(HRegion region, String why, int priority, @@ -336,6 +338,11 @@ private void requestCompactionInternal(HRegion region, String why, int priority, protected void requestCompactionInternal(HRegion region, HStore store, String why, int priority, boolean selectNow, CompactionLifeCycleTracker tracker, CompactionCompleteTracker completeTracker, User user) throws IOException { + if (!this.isCompactionsEnabled()) { + LOG.info("Ignoring compaction request for " + region + ",because compaction is disabled."); + return; + } + if ( this.server.isStopped() || (region.getTableDescriptor() != null && !region.getTableDescriptor().isCompactionEnabled())