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
|
// apply it to a region in this state, as it may lead to data loss as we
|
||||||
// may have some data in recovered edits.
|
// 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
|
* Convert to protobuf ClusterStatusProtos.RegionState.State
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1293,14 +1293,17 @@ public class AssignmentManager {
|
||||||
}
|
}
|
||||||
RegionStateNode regionNode = regionStates.getOrCreateRegionStateNode(regionInfo);
|
RegionStateNode regionNode = regionStates.getOrCreateRegionStateNode(regionInfo);
|
||||||
// Do not need to lock on regionNode, as we can make sure that before we finish loading
|
// Do not need to lock on regionNode, as we can make sure that before we finish loading
|
||||||
// meta, all the related procedures can not be executed. The only exception is formeta
|
// meta, all the related procedures can not be executed. The only exception is for meta
|
||||||
// region related operations, but here we do not load the informations for meta region.
|
// region related operations, but here we do not load the informations for meta region.
|
||||||
regionNode.setState(localState);
|
regionNode.setState(localState);
|
||||||
regionNode.setLastHost(lastHost);
|
regionNode.setLastHost(lastHost);
|
||||||
regionNode.setRegionLocation(regionLocation);
|
regionNode.setRegionLocation(regionLocation);
|
||||||
regionNode.setOpenSeqNum(openSeqNum);
|
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;
|
assert regionLocation != null : "found null region location for " + regionNode;
|
||||||
regionStates.addRegionToServer(regionNode);
|
regionStates.addRegionToServer(regionNode);
|
||||||
} else if (localState == State.OFFLINE || regionInfo.isOffline()) {
|
} else if (localState == State.OFFLINE || regionInfo.isOffline()) {
|
||||||
|
|
|
@ -146,15 +146,17 @@ public class RegionStateNode implements Comparable<RegionStateNode> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInState(final State... expected) {
|
/**
|
||||||
if (expected != null && expected.length > 0) {
|
* Notice that, we will return true if {@code expected} is empty.
|
||||||
boolean expectedState = false;
|
* <p/>
|
||||||
for (int i = 0; i < expected.length; ++i) {
|
* This is a bit strange but we need this logic, for example, we can change the state to OPENING
|
||||||
expectedState |= (getState() == expected[i]);
|
* from any state, as in SCP we will not change the state to CLOSED before opening the region.
|
||||||
}
|
*/
|
||||||
return expectedState;
|
public boolean isInState(State... expected) {
|
||||||
|
if (expected.length == 0) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return getState().matches(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStuck() {
|
public boolean isStuck() {
|
||||||
|
|
|
@ -172,6 +172,9 @@ public class ServerCrashProcedure
|
||||||
services.getAssignmentManager().getRegionsOnServer(serverName);
|
services.getAssignmentManager().getRegionsOnServer(serverName);
|
||||||
// Where to go next? Depends on whether we should split logs at all or
|
// Where to go next? Depends on whether we should split logs at all or
|
||||||
// if we should do distributed log splitting.
|
// if we should do distributed log splitting.
|
||||||
|
if (regionsOnCrashedServer != null) {
|
||||||
|
LOG.info("{} had {} regions", serverName, regionsOnCrashedServer.size());
|
||||||
|
}
|
||||||
if (!this.shouldSplitWal) {
|
if (!this.shouldSplitWal) {
|
||||||
setNextState(ServerCrashState.SERVER_CRASH_ASSIGN);
|
setNextState(ServerCrashState.SERVER_CRASH_ASSIGN);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue