diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java index f69afe9f692..5d8d836e4b1 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java @@ -2636,11 +2636,11 @@ public class AssignmentManager extends ZooKeeperListener { threadPoolExecutorService.submit(new UnAssignCallable(this, regionInfo)); } - boolean isCarryingRoot(ServerName serverName) { + public boolean isCarryingRoot(ServerName serverName) { return isCarryingRegion(serverName, HRegionInfo.ROOT_REGIONINFO); } - boolean isCarryingMeta(ServerName serverName) { + public boolean isCarryingMeta(ServerName serverName) { return isCarryingRegion(serverName, HRegionInfo.FIRST_META_REGIONINFO); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java index d6e5fca5623..f325708fb35 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java @@ -196,20 +196,33 @@ public class ServerShutdownHandler extends EventHandler { // Assign root and meta if we were carrying them. if (isCarryingRoot()) { // -ROOT- - LOG.info("Server " + serverName + - " was carrying ROOT. Trying to assign."); - this.services.getAssignmentManager(). - regionOffline(HRegionInfo.ROOT_REGIONINFO); - verifyAndAssignRootWithRetries(); + // Check again: region may be assigned to other where because of RIT + // timeout + if (this.services.getAssignmentManager().isCarryingRoot(serverName)) { + LOG.info("Server " + serverName + + " was carrying ROOT. Trying to assign."); + this.services.getAssignmentManager().regionOffline( + HRegionInfo.ROOT_REGIONINFO); + verifyAndAssignRootWithRetries(); + } else { + LOG.info("ROOT has been assigned to otherwhere, skip assigning."); + } } // Carrying meta? if (isCarryingMeta()) { - LOG.info("Server " + serverName + - " was carrying META. Trying to assign."); - this.services.getAssignmentManager(). - regionOffline(HRegionInfo.FIRST_META_REGIONINFO); - this.services.getAssignmentManager().assignMeta(); + // Check again: region may be assigned to other where because of RIT + // timeout + if (this.services.getAssignmentManager().isCarryingMeta(serverName)) { + LOG.info("Server " + serverName + + " was carrying META. Trying to assign."); + this.services.getAssignmentManager().regionOffline( + HRegionInfo.FIRST_META_REGIONINFO); + this.services.getAssignmentManager().assignMeta(); + } else { + LOG.info("META has been assigned to otherwhere, skip assigning."); + } + } // We don't want worker thread in the MetaServerShutdownHandler