HBASE-14875 Forward port HBASE-14207 'Region was hijacked and remained in transition when RS failed to open a region and later regionplan changed to new RS on retry'

This commit is contained in:
tedyu 2015-11-24 14:30:37 -08:00
parent 07b07300b8
commit 1917516ffd
1 changed files with 7 additions and 1 deletions

View File

@ -2051,7 +2051,7 @@ public class AssignmentManager extends ZooKeeperListener {
* @param forceNewPlan
*/
private void assign(RegionState state,
final boolean setOfflineInZK, final boolean forceNewPlan) {
boolean setOfflineInZK, final boolean forceNewPlan) {
long startTime = EnvironmentEdgeManager.currentTime();
try {
Configuration conf = server.getConfiguration();
@ -2097,6 +2097,7 @@ public class AssignmentManager extends ZooKeeperListener {
return;
}
if (setOfflineInZK && versionOfOfflineNode == -1) {
LOG.info("Setting node as OFFLINED in ZooKeeper for region " + region);
// get the version of the znode after setting it to OFFLINE.
// versionOfOfflineNode will be -1 if the znode was not set to OFFLINE
versionOfOfflineNode = setOfflineInZooKeeper(currentState, plan.getDestination());
@ -2266,8 +2267,13 @@ public class AssignmentManager extends ZooKeeperListener {
// Clean out plan we failed execute and one that doesn't look like it'll
// succeed anyways; we need a new plan!
// Transition back to OFFLINE
LOG.info("Region assignment plan changed from " + plan.getDestination() + " to "
+ newPlan.getDestination() + " server.");
currentState = regionStates.updateRegionState(region, State.OFFLINE);
versionOfOfflineNode = -1;
if (useZKForAssignment) {
setOfflineInZK = true;
}
plan = newPlan;
} else if(plan.getDestination().equals(newPlan.getDestination()) &&
previousException instanceof FailedServerException) {