HBASE-21614 RIT recovery with ServerCrashProcedure doesn't account for all regions
Signed-off-by: zhangduo <zhangduo@apache.org>
This commit is contained in:
parent
f053003ce7
commit
37bc1686d6
|
@ -59,6 +59,15 @@ public class RegionState {
|
|||
// apply it to a region in this state, as it may lead to data loss as we
|
||||
// may have some data in recovered edits.
|
||||
|
||||
public boolean matches(State... expected) {
|
||||
for (State state : expected) {
|
||||
if (this == state) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to protobuf ClusterStatusProtos.RegionState.State
|
||||
*/
|
||||
|
|
|
@ -1300,7 +1300,10 @@ public class AssignmentManager {
|
|||
regionNode.setRegionLocation(regionLocation);
|
||||
regionNode.setOpenSeqNum(openSeqNum);
|
||||
|
||||
if (localState == State.OPEN) {
|
||||
// Note: keep consistent with other methods, see region(Opening|Opened|Closing)
|
||||
// RIT/ServerCrash handling should take care of the transiting regions.
|
||||
if (localState.matches(State.OPEN, State.OPENING, State.CLOSING, State.SPLITTING,
|
||||
State.MERGING)) {
|
||||
assert regionLocation != null : "found null region location for " + regionNode;
|
||||
regionStates.addRegionToServer(regionNode);
|
||||
} else if (localState == State.OFFLINE || regionInfo.isOffline()) {
|
||||
|
|
|
@ -146,16 +146,18 @@ public class RegionStateNode implements Comparable<RegionStateNode> {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isInState(final State... expected) {
|
||||
if (expected != null && expected.length > 0) {
|
||||
boolean expectedState = false;
|
||||
for (int i = 0; i < expected.length; ++i) {
|
||||
expectedState |= (getState() == expected[i]);
|
||||
}
|
||||
return expectedState;
|
||||
}
|
||||
/**
|
||||
* Notice that, we will return true if {@code expected} is empty.
|
||||
* <p/>
|
||||
* This is a bit strange but we need this logic, for example, we can change the state to OPENING
|
||||
* from any state, as in SCP we will not change the state to CLOSED before opening the region.
|
||||
*/
|
||||
public boolean isInState(State... expected) {
|
||||
if (expected.length == 0) {
|
||||
return true;
|
||||
}
|
||||
return getState().matches(expected);
|
||||
}
|
||||
|
||||
public boolean isStuck() {
|
||||
return isInState(State.FAILED_OPEN) && getProcedure() != null;
|
||||
|
|
|
@ -172,6 +172,9 @@ public class ServerCrashProcedure
|
|||
services.getAssignmentManager().getRegionsOnServer(serverName);
|
||||
// Where to go next? Depends on whether we should split logs at all or
|
||||
// if we should do distributed log splitting.
|
||||
if (regionsOnCrashedServer != null) {
|
||||
LOG.info("{} had {} regions", serverName, regionsOnCrashedServer.size());
|
||||
}
|
||||
if (!this.shouldSplitWal) {
|
||||
setNextState(ServerCrashState.SERVER_CRASH_ASSIGN);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue