From cfeb26d27a3f5c80e5e8e3d29fd94921251075c4 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Thu, 7 Jun 2018 09:50:54 -0700 Subject: [PATCH] HBASE-20702 Processing crash, skip ONLINE'ing empty rows Signed-off-by: Josh Elser --- .../hbase/master/assignment/AssignmentManager.java | 13 +++++++++++-- .../hbase/master/assignment/RegionStateStore.java | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java index 35e4aa4f1bf..3c9b0d3d030 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java @@ -48,6 +48,7 @@ import org.apache.hadoop.hbase.YouAreDeadException; import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.client.RegionInfoBuilder; import org.apache.hadoop.hbase.client.RegionReplicaUtil; +import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.TableState; import org.apache.hadoop.hbase.exceptions.UnexpectedStateException; import org.apache.hadoop.hbase.favored.FavoredNodesManager; @@ -77,6 +78,7 @@ import org.apache.hadoop.hbase.procedure2.ProcedureEvent; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; import org.apache.hadoop.hbase.procedure2.ProcedureInMemoryChore; import org.apache.hadoop.hbase.procedure2.util.StringUtils; +import org.apache.hadoop.hbase.regionserver.SequenceId; import org.apache.hadoop.hbase.util.HasThread; import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting; import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; @@ -1235,9 +1237,14 @@ public class AssignmentManager implements ServerListener { // TODO: use a thread pool regionStateStore.visitMeta(new RegionStateStore.RegionStateVisitor() { @Override - public void visitRegionState(final RegionInfo regionInfo, final State state, + public void visitRegionState(Result result, final RegionInfo regionInfo, final State state, final ServerName regionLocation, final ServerName lastHost, final long openSeqNum) { - final RegionStateNode regionNode = regionStates.getOrCreateRegionStateNode(regionInfo); + if (state == null && regionLocation == null && lastHost == null && + openSeqNum == SequenceId.NO_SEQUENCE_ID) { + // This is a row with nothing in it. + LOG.warn("Skipping empty row={}", result); + return; + } State localState = state; if (localState == null) { // No region state column data in hbase:meta table! Are I doing a rolling upgrade from @@ -1245,8 +1252,10 @@ public class AssignmentManager implements ServerListener { // In any of these cases, state is empty. For now, presume OFFLINE but there are probably // cases where we need to probe more to be sure this correct; TODO informed by experience. LOG.info(regionInfo.getEncodedName() + " regionState=null; presuming " + State.OFFLINE); + localState = State.OFFLINE; } + final RegionStateNode regionNode = regionStates.getOrCreateRegionStateNode(regionInfo); synchronized (regionNode) { if (!regionNode.isInTransition()) { regionNode.setState(localState); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateStore.java index 81f0f0a2660..fa252316d62 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateStore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateStore.java @@ -68,7 +68,7 @@ public class RegionStateStore { } public interface RegionStateVisitor { - void visitRegionState(RegionInfo regionInfo, State state, + void visitRegionState(Result result, RegionInfo regionInfo, State state, ServerName regionLocation, ServerName lastHost, long openSeqNum); } @@ -121,7 +121,7 @@ public class RegionStateStore { // TODO: move under trace, now is visible for debugging LOG.info("Load hbase:meta entry region={}, regionState={}, lastHost={}, " + "regionLocation={}", regionInfo.getEncodedName(), state, lastHost, regionLocation); - visitor.visitRegionState(regionInfo, state, regionLocation, lastHost, openSeqNum); + visitor.visitRegionState(result, regionInfo, state, regionLocation, lastHost, openSeqNum); } }