sandeepvinayak 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_r350379111
 
 

 ##########
 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:
   @guangxuCheng @wchevreuil  done, thanks for pointing it out. 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to