HBASE-9773 Master aborted when hbck asked the master to assign a region that was already online

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1532633 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jxiang 2013-10-16 02:44:59 +00:00
parent 76b5c4f3cc
commit c610e59c0d
2 changed files with 16 additions and 3 deletions

View File

@ -1684,6 +1684,9 @@ public class AssignmentManager extends ZooKeeperListener {
versionOfClosingNode, dest, transitionInZK)) {
LOG.debug("Sent CLOSE to " + server + " for region " +
region.getRegionNameAsString());
if (!transitionInZK && state != null) {
regionOffline(region);
}
return;
}
// This never happens. Currently regionserver close always return true.

View File

@ -112,11 +112,21 @@ public class TestAssignmentManagerOnCluster {
HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
master.assignRegion(hri);
master.getAssignmentManager().waitForAssignment(hri);
AssignmentManager am = master.getAssignmentManager();
am.waitForAssignment(hri);
ServerName serverName = master.getAssignmentManager().
getRegionStates().getRegionServerOfRegion(hri);
RegionStates regionStates = am.getRegionStates();
ServerName serverName = regionStates.getRegionServerOfRegion(hri);
TEST_UTIL.assertRegionOnServer(hri, serverName, 200);
// Region is assigned now. Let's assign it again.
// Master should not abort, and region should be assigned.
RegionState oldState = regionStates.getRegionState(hri);
TEST_UTIL.getHBaseAdmin().assign(hri.getRegionName());
master.getAssignmentManager().waitForAssignment(hri);
RegionState newState = regionStates.getRegionState(hri);
assertTrue(newState.isOpened()
&& newState.getStamp() != oldState.getStamp());
} finally {
TEST_UTIL.deleteTable(Bytes.toBytes(table));
}