HBASE-9525 "Move" region right after a region split is dangerous

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1523832 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jxiang 2013-09-16 23:05:30 +00:00
parent ed90c565ef
commit e7195a2e3c
3 changed files with 26 additions and 7 deletions

View File

@ -2295,6 +2295,13 @@ public class AssignmentManager extends ZooKeeperListener {
RegionState state = regionStates.getRegionTransitionState(encodedName);
try {
if (state == null) {
// Region is not in transition.
// We can unassign it only if it's not SPLIT/MERGED.
state = regionStates.getRegionState(encodedName);
if (state.isMerged() || state.isSplit()) {
LOG.info("Attempting to unassign " + state + ", ignored");
return;
}
// Create the znode in CLOSING state
try {
state = regionStates.getRegionState(region);
@ -2307,7 +2314,7 @@ public class AssignmentManager extends ZooKeeperListener {
versionOfClosingNode = ZKAssign.createNodeClosing(
watcher, region, state.getServerName());
if (versionOfClosingNode == -1) {
LOG.debug("Attempting to unassign " +
LOG.info("Attempting to unassign " +
region.getRegionNameAsString() + " but ZK closing node "
+ "can't be created.");
return;

View File

@ -140,9 +140,15 @@ public class TestRegionMergeTransactionOnCluster {
// We should not be able to assign it again
am.assign(hri, true, true);
assertFalse("Merged region should not be in transition again",
regionStates.isRegionInTransition(hri)
&& regionStates.isRegionInState(hri, State.MERGED));
assertFalse("Merged region can't be assigned",
regionStates.isRegionInTransition(hri));
assertTrue(regionStates.isRegionInState(hri, State.MERGED));
// We should not be able to unassign it either
am.unassign(hri, true, null);
assertFalse("Merged region can't be unassigned",
regionStates.isRegionInTransition(hri));
assertTrue(regionStates.isRegionInState(hri, State.MERGED));
table.close();
}

View File

@ -850,9 +850,15 @@ public class TestSplitTransactionOnCluster {
// We should not be able to assign it again
am.assign(hri, true, true);
assertFalse("Split region should not be in transition again",
regionStates.isRegionInTransition(hri)
&& regionStates.isRegionInState(hri, State.SPLIT));
assertFalse("Split region can't be assigned",
regionStates.isRegionInTransition(hri));
assertTrue(regionStates.isRegionInState(hri, State.SPLIT));
// We should not be able to unassign it either
am.unassign(hri, true, null);
assertFalse("Split region can't be unassigned",
regionStates.isRegionInTransition(hri));
assertTrue(regionStates.isRegionInState(hri, State.SPLIT));
} finally {
admin.setBalancerRunning(true, false);
cluster.getMaster().setCatalogJanitorEnabled(true);