From f690e086f6f9f720dbbd85fa28c3c814b744196c Mon Sep 17 00:00:00 2001 From: ramkrishna Date: Mon, 25 Jun 2012 18:07:32 +0000 Subject: [PATCH] HBASE-5875 Process RIT and Master restart may remove an online server considering it as a dead server (Rajesh) Submitted by:Rajesh Reviewed by:Ram Ted, Stack git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1353688 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/hadoop/hbase/master/HMaster.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) 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 b7f5f2e90f9..f6b5472e4cb 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 @@ -748,7 +748,8 @@ Server { boolean rit = this.assignmentManager. processRegionInTransitionAndBlockUntilAssigned(HRegionInfo.ROOT_REGIONINFO); ServerName currentRootServer = null; - if (!catalogTracker.verifyRootRegionLocation(timeout)) { + boolean rootRegionLocation = catalogTracker.verifyRootRegionLocation(timeout); + if (!rit && !rootRegionLocation) { currentRootServer = this.catalogTracker.getRootLocation(); splitLogAndExpireIfOnline(currentRootServer); this.assignmentManager.assignRoot(); @@ -757,7 +758,13 @@ Server { // This guarantees that the transition assigning -ROOT- has completed this.assignmentManager.waitForAssignment(HRegionInfo.ROOT_REGIONINFO); assigned++; - } else { + } else if (rit && !rootRegionLocation) { + // Make sure a -ROOT- location is set. + if (!isRootLocation()) return false; + // This guarantees that the transition assigning -ROOT- has completed + this.assignmentManager.waitForAssignment(HRegionInfo.ROOT_REGIONINFO); + assigned++; + } else if (rootRegionLocation) { // Region already assigned. We didn't assign it. Add to in-memory state. this.assignmentManager.regionOnline(HRegionInfo.ROOT_REGIONINFO, this.catalogTracker.getRootLocation()); @@ -774,7 +781,8 @@ Server { status.setStatus("Assigning META region"); rit = this.assignmentManager. processRegionInTransitionAndBlockUntilAssigned(HRegionInfo.FIRST_META_REGIONINFO); - if (!this.catalogTracker.verifyMetaRegionLocation(timeout)) { + boolean metaRegionLocation = this.catalogTracker.verifyMetaRegionLocation(timeout); + if (!rit && !metaRegionLocation) { ServerName currentMetaServer = this.catalogTracker.getMetaLocationOrReadLocationFromRoot(); if (currentMetaServer != null @@ -782,11 +790,11 @@ Server { splitLogAndExpireIfOnline(currentMetaServer); } assignmentManager.assignMeta(); - enableServerShutdownHandler(); - this.catalogTracker.waitForMeta(); - // Above check waits for general meta availability but this does not - // guarantee that the transition has completed - this.assignmentManager.waitForAssignment(HRegionInfo.FIRST_META_REGIONINFO); + enableSSHandWaitForMeta(); + assigned++; + } else if (rit && !metaRegionLocation) { + // Wait until META region added to region server onlineRegions. See HBASE-5875. + enableSSHandWaitForMeta(); assigned++; } else { // Region already assigned. We didnt' assign it. Add to in-memory state. @@ -800,6 +808,14 @@ Server { return true; } + private void enableSSHandWaitForMeta() throws IOException, InterruptedException { + enableServerShutdownHandler(); + this.catalogTracker.waitForMeta(); + // Above check waits for general meta availability but this does not + // guarantee that the transition has completed + this.assignmentManager.waitForAssignment(HRegionInfo.FIRST_META_REGIONINFO); + } + /** * @return True if there a root available * @throws InterruptedException