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 2020/07/21 19:25:37 UTC

[GitHub] [hbase] busbey commented on a change in pull request #2113: HBASE-24286: HMaster won't become healthy after after cloning or crea…

busbey commented on a change in pull request #2113:
URL: https://github.com/apache/hbase/pull/2113#discussion_r458332118



##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRecreateCluster.java
##########
@@ -0,0 +1,185 @@
+/**

Review comment:
       nit: this should be a non-javadoc comment

##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRecreateCluster.java
##########
@@ -0,0 +1,185 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.master;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.time.Duration;
+import java.util.List;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.MiniHBaseCluster;
+import org.apache.hadoop.hbase.StartMiniClusterOption;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore;
+import org.apache.hadoop.hbase.regionserver.HRegionServer;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.zookeeper.ZooKeeperHelper;
+import org.apache.zookeeper.ZKUtil;
+import org.apache.zookeeper.ZooKeeper;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
+/**
+ * Test reuse data directory when cluster failover with a set of new region servers with
+ * different hostnames. For any hbase system table and user table can be assigned normally after
+ * cluster restart
+ */
+@Category({ LargeTests.class })
+public class TestRecreateCluster {
+  @ClassRule
+  public static final HBaseClassTestRule CLASS_RULE =
+      HBaseClassTestRule.forClass(TestRecreateCluster.class);
+
+  @Rule
+  public TestName name = new TestName();
+
+  private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+  private static final int NUM_RS = 3;
+  private static final long LIVE_REGION_SERVER_TIMEOUT_MS = Duration.ofMinutes(3).toMillis();
+
+  @Test
+  public void testRecreateCluster_UserTableDisabled() throws Exception {
+    TEST_UTIL.startMiniCluster(NUM_RS);
+    try {
+      TableName tableName = TableName.valueOf("t1");
+      prepareDataBeforeRecreate(TEST_UTIL, tableName);
+      TEST_UTIL.getAdmin().disableTable(tableName);
+      TEST_UTIL.waitTableDisabled(tableName.getName());
+      restartCluster();
+      TEST_UTIL.getAdmin().enableTable(tableName);
+      validateDataAfterRecreate(TEST_UTIL, tableName);
+    } finally {
+      TEST_UTIL.shutdownMiniCluster();
+    }
+  }
+
+  @Test
+  public void testRecreateCluster_UserTableEnabled() throws Exception {
+    TEST_UTIL.startMiniCluster(NUM_RS);
+    try {
+      TableName tableName = TableName.valueOf("t1");
+      prepareDataBeforeRecreate(TEST_UTIL, tableName);
+      restartCluster();
+      validateDataAfterRecreate(TEST_UTIL, tableName);
+    } finally {
+      TEST_UTIL.shutdownMiniCluster();
+    }
+  }
+
+  private void restartCluster() throws Exception {
+    // flush cache so that everything is on disk
+    TEST_UTIL.getMiniHBaseCluster().flushcache();
+
+    // delete all wal data
+    Path walRootPath = TEST_UTIL.getMiniHBaseCluster().getMaster().getWALRootDir();
+    TEST_UTIL.shutdownMiniHBaseCluster();
+    TEST_UTIL.getDFSCluster().getFileSystem().delete(
+        new Path(walRootPath.toString(), HConstants.HREGION_LOGDIR_NAME), true);
+    TEST_UTIL.getDFSCluster().getFileSystem().delete(

Review comment:
       should we have some check before this that the cluster successfully cleanly shut down and thus has no procedures pending?
   
   if we are expressly trying to test that we can come up safely after having the master procedure wal destroyed while things are in-flight then we should make that a test case.

##########
File path: hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
##########
@@ -218,6 +222,20 @@ int scan() throws IOException {
     }
   }
 
+  void repairUnknownServers() {
+    if(!lastReport.unknownServers.isEmpty()) {
+      // submit HBCKServerCrashProcedure to avoid any corner cases that in-memory region states
+      // mismatches with hbase:meta. in fact if HBCKSCP finds any in-memory region states,
+      // HBCKSCP is basically same as SCP.
+      lastReport.unknownServers.stream().forEach(regionInfoServerNamePair -> {
+        LOG.warn("Submitting HBCKSCP for Unknown Region Server {}",

Review comment:
       should this be at INFO level? if it is at WARN what can an operator do to prevent future warnings? if this is something that is going to happen as a matter of course then INFO is more appropriate.




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