From 407cda4a0c4bc1338af175299372a4b1976bb44a Mon Sep 17 00:00:00 2001 From: tedyu Date: Tue, 5 Jan 2016 06:24:42 -0800 Subject: [PATCH] HBASE-15058 AssignmentManager should account for unsuccessful split correctly which initially passes quota check --- .../hbase/master/AssignmentManager.java | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) 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 fd5d192e1a2..83f9d722404 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 @@ -3720,7 +3720,7 @@ public class AssignmentManager extends ZooKeeperListener { invokeAssign(hri, false); } - private String onRegionSplit(ServerName sn, TransitionCode code, + private String checkInStateForSplit(ServerName sn, final HRegionInfo p, final HRegionInfo a, final HRegionInfo b) { final RegionState rs_p = regionStates.getRegionState(p); RegionState rs_a = regionStates.getRegionState(a); @@ -3730,6 +3730,32 @@ public class AssignmentManager extends ZooKeeperListener { && (rs_b == null || rs_b.isOpenOrSplittingNewOnServer(sn)))) { return "Not in state good for split"; } + return ""; + } + + private String onRegionSplitReverted(ServerName sn, + final HRegionInfo p, final HRegionInfo a, final HRegionInfo b) { + String s = checkInStateForSplit(sn, p, a, b); + if (!org.apache.commons.lang.StringUtils.isEmpty(s)) { + return s; + } + regionOnline(p, sn); + regionOffline(a); + regionOffline(b); + + if (getTableStateManager().isTableState(p.getTable(), + ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING)) { + invokeUnAssign(p); + } + return null; + } + + private String onRegionSplit(ServerName sn, TransitionCode code, + final HRegionInfo p, final HRegionInfo a, final HRegionInfo b) { + String s = checkInStateForSplit(sn, p, a, b); + if (!org.apache.commons.lang.StringUtils.isEmpty(s)) { + return s; + } regionStates.updateRegionState(a, State.SPLITTING_NEW, sn); regionStates.updateRegionState(b, State.SPLITTING_NEW, sn); @@ -3765,15 +3791,6 @@ public class AssignmentManager extends ZooKeeperListener { LOG.info("Failed to record split region " + p.getShortNameToLog()); return "Failed to record the splitting in meta"; } - } else if (code == TransitionCode.SPLIT_REVERTED) { - regionOnline(p, sn); - regionOffline(a); - regionOffline(b); - - if (getTableStateManager().isTableState(p.getTable(), - ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING)) { - invokeUnAssign(p); - } } return null; } @@ -4338,11 +4355,18 @@ public class AssignmentManager extends ZooKeeperListener { } catch (IOException exp) { errorMsg = StringUtils.stringifyException(exp); } + break; case SPLIT_PONR: case SPLIT: + errorMsg = + onRegionSplit(serverName, code, hri, HRegionInfo.convert(transition.getRegionInfo(1)), + HRegionInfo.convert(transition.getRegionInfo(2))); + break; + case SPLIT_REVERTED: errorMsg = - onRegionSplit(serverName, code, hri, HRegionInfo.convert(transition.getRegionInfo(1)), + onRegionSplitReverted(serverName, hri, + HRegionInfo.convert(transition.getRegionInfo(1)), HRegionInfo.convert(transition.getRegionInfo(2))); if (org.apache.commons.lang.StringUtils.isEmpty(errorMsg)) { try {