From d525629eb57551951e56f9ea35c5c50eb575de95 Mon Sep 17 00:00:00 2001 From: guluo Date: Thu, 6 Jul 2023 10:32:38 +0800 Subject: [PATCH] HBASE-27859 HMaster.getCompactionState can happen NPE when region state is closed (#5232) Signed-off-by: Duo Zhang Signed-off-by: Wellington Chevreuil (cherry picked from commit b2e2abe64bd9f3d511b8193510fe66c76ff7854c) --- .../main/java/org/apache/hadoop/hbase/master/HMaster.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 3d59db245015..8cb40cb58803 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -4208,6 +4208,11 @@ public CompactionState getCompactionState(final TableName tableName) { continue; } RegionMetrics regionMetrics = sl.getRegionMetrics().get(regionInfo.getRegionName()); + if (regionMetrics == null) { + LOG.warn("Can not get compaction details for the region: {} , it may be not online.", + regionInfo.getRegionNameAsString()); + continue; + } if (regionMetrics.getCompactionState() == CompactionState.MAJOR) { if (compactionState == CompactionState.MINOR) { compactionState = CompactionState.MAJOR_AND_MINOR;