HBASE-23035 Retain region to the last RegionServer make the failover slower (#631)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
Guanghao Zhang 2019-09-21 21:11:05 +08:00 committed by GitHub
parent 3ae353cbf4
commit cb04c6c1a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -398,6 +398,11 @@ public class TransitRegionStateProcedure
// 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);
@ -545,8 +550,13 @@ public class TransitRegionStateProcedure
// 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) {

View File

@ -464,7 +464,9 @@ public class ServerCrashProcedure
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);
}