From a26cbf105743de28c62a6442eba2ef04d17d46af Mon Sep 17 00:00:00 2001 From: chenglei Date: Thu, 8 Sep 2022 16:39:12 +0800 Subject: [PATCH] HBASE-27362 CompactSplit.requestCompactionInternal may bypass compactionsEnabled check (#4768) Co-authored-by: comnetwork Signed-off-by: Duo Zhang --- .../hadoop/hbase/regionserver/CompactSplit.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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())