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 df514cbdeb2..897d97056f1 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 @@ -3013,6 +3013,11 @@ public class AssignmentManager extends ZooKeeperListener { } catch (KeeperException ke) { server.abort("Unexpected ZK exception deleting node " + hri, ke); } + if (zkTable.isDisablingOrDisabledTable(hri.getTableNameAsString())) { + it.remove(); + regionStates.regionOffline(hri); + continue; + } // Mark the region closed and assign it again by SSH regionStates.updateRegionState(hri, RegionState.State.CLOSED); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java index 033cb347de8..47a533d1ba3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java @@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer; import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.FSUtils; +import org.apache.hadoop.hbase.zookeeper.ZKAssign; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -387,6 +388,41 @@ public class TestAssignmentManagerOnCluster { TEST_UTIL.deleteTable(Bytes.toBytes(table)); } } + + @Test + public void testSSHWhenDisablingTableRegionsInOpeningOrPendingOpenState() throws Exception { + final String table = "testSSHWhenDisablingTableRegionsInOpeningOrPendingOpenState"; + AssignmentManager am = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager(); + HRegionInfo hri = null; + ServerName serverName = null; + try { + hri = createTableAndGetOneRegion(table); + serverName = am.getRegionStates().getRegionServerOfRegion(hri); + ServerName destServerName = null; + HRegionServer destServer = null; + for (int i = 0; i < 3; i++) { + destServer = TEST_UTIL.getHBaseCluster().getRegionServer(i); + if (!destServer.getServerName().equals(serverName)) { + destServerName = destServer.getServerName(); + break; + } + } + am.regionOffline(hri); + ZKAssign.createNodeOffline(TEST_UTIL.getHBaseCluster().getMaster().getZooKeeper(), hri, + destServerName); + ZKAssign.transitionNodeOpening(TEST_UTIL.getHBaseCluster().getMaster().getZooKeeper(), hri, + destServerName); + am.getZKTable().setDisablingTable(table); + List toAssignRegions = am.processServerShutdown(destServerName); + assertTrue("Regions to be assigned should be empty.", toAssignRegions.isEmpty()); + assertTrue("Regions to be assigned should be empty.", am.getRegionStates() + .getRegionState(hri).isOffline()); + } finally { + am.regionOnline(hri, serverName); + am.getZKTable().setDisabledTable(table); + TEST_UTIL.deleteTable(Bytes.toBytes(table)); + } + } static class MockLoadBalancer extends StochasticLoadBalancer { // For this region, if specified, always assign to nowhere