Index: src/main/java/org/apache/hadoop/hbase/master/HMaster.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/master/HMaster.java (revision 1353643) +++ src/main/java/org/apache/hadoop/hbase/master/HMaster.java (working copy) @@ -625,18 +625,20 @@ 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(); - this.catalogTracker.waitForRoot(); - //This guarantees that the transition has completed - this.assignmentManager.waitForAssignment(HRegionInfo.ROOT_REGIONINFO); + waitForRootAssignment(); assigned++; + } else if (rit && !rootRegionLocation) { + waitForRootAssignment(); + assigned++; } else { - // Region already assigned. We didn't assign it. Add to in-memory state. + // Region already assigned. We didn't assign it. Add to in-memory state. this.assignmentManager.regionOnline(HRegionInfo.ROOT_REGIONINFO, - this.catalogTracker.getRootLocation()); + this.catalogTracker.getRootLocation()); } // Enable the ROOT table if on process fail over the RS containing ROOT // was active. @@ -648,7 +650,8 @@ 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 @@ -656,12 +659,11 @@ 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) { + enableSSHandWaitForMeta(); + assigned++; } else { // Region already assigned. We didnt' assign it. Add to in-memory state. this.assignmentManager.regionOnline(HRegionInfo.FIRST_META_REGIONINFO, @@ -674,6 +676,22 @@ return assigned; } + 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); + } + + private void waitForRootAssignment() throws InterruptedException { + this.catalogTracker.waitForRoot(); + // This guarantees that the transition has completed + this.assignmentManager.waitForAssignment(HRegionInfo.ROOT_REGIONINFO); + } + private void enableCatalogTables(String catalogTableName) { if (!this.assignmentManager.getZKTable().isEnabledTable(catalogTableName)) { this.assignmentManager.setEnabledTable(catalogTableName);