You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2019/11/24 04:19:25 UTC

[GitHub] [hbase] guangxuCheng commented on a change in pull request #867: HBASE-23117: Bad enum in hbase:meta info:state column can fail loadMeta and stop startup

guangxuCheng commented on a change in pull request #867: HBASE-23117: Bad enum in hbase:meta info:state column can fail loadMeta and stop startup
URL: https://github.com/apache/hbase/pull/867#discussion_r349902208
 
 

 ##########
 File path: hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionStateStore.java
 ##########
 @@ -84,6 +89,36 @@ public void visitRegionState(Result result, RegionInfo regionInfo, RegionState.S
     assertTrue("Visitor has not been called.", visitorCalled.get());
   }
 
+  @Test
+  public void testVisitMetaForBadRegionState() throws Exception {
+    final TableName tableName = TableName.valueOf("testVisitMetaForBadRegionState");
+    util.createTable(tableName, "cf");
+    final List<HRegion> regions = util.getHBaseCluster().getRegions(tableName);
+    final String encodedName = regions.get(0).getRegionInfo().getEncodedName();
+    final RegionStateStore regionStateStore = util.getHBaseCluster().getMaster().
+        getAssignmentManager().getRegionStateStore();
+
+    // add the BAD_STATE which does not exist in enum RegionState.State
+    Put put = new Put(regions.get(0).getRegionInfo().getRegionName(), EnvironmentEdgeManager.currentTime());
+    put.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER,
+        Bytes.toBytes("BAD_STATE"));
+
+    try (Table table = util.getConnection().getTable(TableName.META_TABLE_NAME)) {
+      table.put(put);
+    }
+
+    final AtomicBoolean visitorCalled = new AtomicBoolean(false);
+    regionStateStore.visitMetaForRegion(encodedName, new RegionStateStore.RegionStateVisitor() {
+      @Override
+      public void visitRegionState(Result result, RegionInfo regionInfo, RegionState.State state,
+                                   ServerName regionLocation, ServerName lastHost, long openSeqNum) {
+        assertEquals(encodedName, regionInfo.getEncodedName());
 
 Review comment:
   Need to check if the state is null

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services