You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2019/11/26 18:24:13 UTC

[hbase] branch branch-2.2 updated: HBASE-23117: Bad enum in hbase:meta info:state column can fail loadMeta and stop startup (#867)

This is an automated email from the ASF dual-hosted git repository.

stack pushed a commit to branch branch-2.2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.2 by this push:
     new 45019db  HBASE-23117: Bad enum in hbase:meta info:state column can fail loadMeta and stop startup (#867)
45019db is described below

commit 45019dbb49c7c4acf808398e1125ec2a10ace0a6
Author: Sandeep Pal <50...@users.noreply.github.com>
AuthorDate: Tue Nov 26 10:10:01 2019 -0800

    HBASE-23117: Bad enum in hbase:meta info:state column can fail loadMeta and stop startup (#867)
    
    * Handling the BAD value in info:state columns in hbase:meta
    
    * Adding a unit test and region encoded name in the LOG
    
    * Adding a null check for region state to complete the test scenario and fixing the nit
    
    Signed-off-by: Wellington Chevreuil <wc...@apache.org>
    Signed-off-by: GuangxuCheng  <gu...@gmail.com>
    Signed-off-by: stack <st...@apache.org>
---
 .../hbase/master/assignment/RegionStateStore.java       | 17 +++++++++++++----
 .../org/apache/hadoop/hbase/HBaseTestingUtility.java    |  2 +-
 2 files changed, 14 insertions(+), 5 deletions(-)

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 dcc38c8..df7f1bb 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
@@ -115,7 +115,7 @@ public class RegionStateStore {
       if (regionInfo == null) continue;
 
       final int replicaId = regionInfo.getReplicaId();
-      final State state = getRegionState(result, replicaId);
+      final State state = getRegionState(result, replicaId, regionInfo);
 
       final ServerName lastHost = hrl.getServerName();
       final ServerName regionLocation = getRegionServer(result, replicaId);
@@ -330,13 +330,22 @@ public class RegionStateStore {
    * @return the region state, or null if unknown.
    */
   @VisibleForTesting
-  public static State getRegionState(final Result r, int replicaId) {
+  public static State getRegionState(final Result r, int replicaId, RegionInfo regionInfo) {
     Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getStateColumn(replicaId));
     if (cell == null || cell.getValueLength() == 0) {
       return null;
     }
-    return State.valueOf(Bytes.toString(cell.getValueArray(), cell.getValueOffset(),
-        cell.getValueLength()));
+
+    String state = Bytes.toString(cell.getValueArray(), cell.getValueOffset(),
+        cell.getValueLength());
+    try {
+      return State.valueOf(state);
+    } catch (IllegalArgumentException e) {
+      LOG.warn("BAD value {} in hbase:meta info:state column for region {} , " +
+              "Consider using HBCK2 setRegionState ENCODED_REGION_NAME STATE",
+          state, regionInfo.getEncodedName());
+      return null;
+    }
   }
 
   private static byte[] getStateColumn(int replicaId) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
index 7b2f2e5..08b89b0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
@@ -3652,7 +3652,7 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
                     }
                   }
                   if (RegionStateStore.getRegionState(r,
-                    info.getReplicaId()) != RegionState.State.OPEN) {
+                    info.getReplicaId(), info) != RegionState.State.OPEN) {
                     return false;
                   }
                 }