Skip to content

Commit

Permalink
HBASE-23035 Retain region to the last RegionServer make the failover …
Browse files Browse the repository at this point in the history
…slower (#631)

Signed-off-by: Duo Zhang <[email protected]>
  • Loading branch information
infraio authored Sep 21, 2019
1 parent 3ae353c commit cb04c6c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,11 @@ public void reportTransition(MasterProcedureEnv env, RegionStateNode regionNode,
// Should be called with RegionStateNode locked
public void serverCrashed(MasterProcedureEnv env, RegionStateNode regionNode,
ServerName serverName) throws IOException {
// force to assign to a new candidate server
// TODO: the forceNewPlan flag not be persistent so if master crash then the flag will be lost.
// But assign to old server is not big deal because it not effect correctness.
// See HBASE-23035 for more details.
forceNewPlan = true;
if (remoteProc != null) {
// this means we are waiting for the sub procedure, so wake it up
remoteProc.serverCrashed(env, regionNode, serverName);
Expand Down Expand Up @@ -545,8 +550,13 @@ public enum TransitionType {
// anything. See the comment in executeFromState to find out why we need this assumption.
public static TransitRegionStateProcedure assign(MasterProcedureEnv env, RegionInfo region,
@Nullable ServerName targetServer) {
return setOwner(env,
new TransitRegionStateProcedure(env, region, targetServer, false, TransitionType.ASSIGN));
return assign(env, region, false, targetServer);
}

public static TransitRegionStateProcedure assign(MasterProcedureEnv env, RegionInfo region,
boolean forceNewPlan, @Nullable ServerName targetServer) {
return setOwner(env, new TransitRegionStateProcedure(env, region, targetServer, forceNewPlan,
TransitionType.ASSIGN));
}

public static TransitRegionStateProcedure unassign(MasterProcedureEnv env, RegionInfo region) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,9 @@ private void assignRegions(MasterProcedureEnv env, List<RegionInfo> regions) thr
TableState.State.DISABLING, TableState.State.DISABLED)) {
continue;
}
TransitRegionStateProcedure proc = TransitRegionStateProcedure.assign(env, region, null);
// force to assign to a new candidate server, see HBASE-23035 for more details.
TransitRegionStateProcedure proc =
TransitRegionStateProcedure.assign(env, region, true, null);
regionNode.setProcedure(proc);
addChildProcedure(proc);
}
Expand Down

0 comments on commit cb04c6c

Please sign in to comment.