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 2021/03/15 23:28:52 UTC

[GitHub] [hbase] saintstack commented on a change in pull request #3001: HBASE-25518 Support separate child regions to different region servers

saintstack commented on a change in pull request #3001:
URL: https://github.com/apache/hbase/pull/3001#discussion_r594754063



##########
File path: hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManagerUtil.java
##########
@@ -189,6 +190,67 @@ private static void unlock(List<RegionStateNode> regionNodes) {
     return ArrayUtils.addAll(primaryRegionProcs, replicaRegionAssignProcs);
   }
 
+  /**
+   * Create round robin assign procedures for the give regions,

Review comment:
       s/give/given/

##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionSplit.java
##########
@@ -146,8 +152,70 @@ public void testSplitTableRegion() throws Exception {
     UTIL.getAdmin().enableTable(tableName);
     Thread.sleep(500);
 
-    assertEquals("Table region not correct.", 2,
-        UTIL.getHBaseCluster().getRegions(tableName).size());
+    List<HRegion> tableRegions = UTIL.getHBaseCluster().getRegions(tableName);
+    assertEquals("Table region not correct.", 2, tableRegions.size());
+    Map<RegionInfo, ServerName> regionInfoMap = UTIL.getHBaseCluster().getMaster().getAssignmentManager()
+      .getRegionStates().getRegionAssignments();
+    assertEquals(regionInfoMap.get(tableRegions.get(0).getRegionInfo()),
+      regionInfoMap.get(tableRegions.get(1).getRegionInfo()));
+  }
+
+  @Test
+  public void testSplitTableRegionAndSeparateChildRegions() throws Exception {
+    cleanupTest();
+    //restart master
+    UTIL.getConfiguration().setBoolean(HConstants.HBASE_ENABLE_SEPARATE_CHILD_REGIONS, true);
+    setupCluster();
+
+    final TableName tableName = TableName.valueOf(name.getMethodName());
+    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
+
+    RegionInfo[] regions =
+      MasterProcedureTestingUtility.createTable(procExec, tableName, null, ColumnFamilyName);
+    insertData(tableName);
+    int splitRowNum = startRowNum + rowCount / 2;
+    byte[] splitKey = Bytes.toBytes("" + splitRowNum);
+
+    assertTrue("not able to find a splittable region", regions != null);
+    assertTrue("not able to find a splittable region", regions.length == 1);
+
+    // Split region of the table
+    long procId = procExec.submitProcedure(
+      new SplitTableRegionProcedure(procExec.getEnvironment(), regions[0], splitKey));
+    // Wait the completion
+    ProcedureTestingUtility.waitProcedure(procExec, procId);
+    ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
+
+    assertTrue("not able to split table", UTIL.getHBaseCluster().getRegions(tableName).size() == 2);
+
+    //disable table
+    UTIL.getAdmin().disableTable(tableName);
+    Thread.sleep(500);
+
+    //stop master
+    UTIL.getHBaseCluster().stopMaster(0);
+    UTIL.getHBaseCluster().waitOnMaster(0);
+    Thread.sleep(500);
+
+    //restart master
+    JVMClusterUtil.MasterThread t = UTIL.getHBaseCluster().startMaster();
+    Thread.sleep(500);
+
+    UTIL.invalidateConnection();
+    // enable table
+    UTIL.getAdmin().enableTable(tableName);
+    Thread.sleep(500);
+
+    List<HRegion> tableRegions = UTIL.getHBaseCluster().getRegions(tableName);
+    assertEquals("Table region not correct.", 2, tableRegions.size());
+    Map<RegionInfo, ServerName> regionInfoMap = UTIL.getHBaseCluster().getMaster().getAssignmentManager()
+      .getRegionStates().getRegionAssignments();
+    assertNotEquals(regionInfoMap.get(tableRegions.get(0).getRegionInfo()),

Review comment:
       How can you be sure the roundrobin will not assign both daughters to same server?

##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionSplit.java
##########
@@ -146,8 +152,70 @@ public void testSplitTableRegion() throws Exception {
     UTIL.getAdmin().enableTable(tableName);
     Thread.sleep(500);
 
-    assertEquals("Table region not correct.", 2,
-        UTIL.getHBaseCluster().getRegions(tableName).size());
+    List<HRegion> tableRegions = UTIL.getHBaseCluster().getRegions(tableName);
+    assertEquals("Table region not correct.", 2, tableRegions.size());
+    Map<RegionInfo, ServerName> regionInfoMap = UTIL.getHBaseCluster().getMaster().getAssignmentManager()
+      .getRegionStates().getRegionAssignments();
+    assertEquals(regionInfoMap.get(tableRegions.get(0).getRegionInfo()),
+      regionInfoMap.get(tableRegions.get(1).getRegionInfo()));
+  }
+
+  @Test
+  public void testSplitTableRegionAndSeparateChildRegions() throws Exception {
+    cleanupTest();

Review comment:
       You should make a new test suite with this test in it rather than do this cleanupTest and setupCluster... These methods are for before the test class and after... not for calling in the test as here.

##########
File path: hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManagerUtil.java
##########
@@ -189,6 +190,67 @@ private static void unlock(List<RegionStateNode> regionNodes) {
     return ArrayUtils.addAll(primaryRegionProcs, replicaRegionAssignProcs);
   }
 
+  /**
+   * Create round robin assign procedures for the give regions,
+   * according to the {@code regionReplication}.
+   * <p/>
+   * For rolling back, we will submit procedures directly to the {@code ProcedureExecutor}, so it is
+   * possible that we persist the newly scheduled procedures, and then crash before persisting the
+   * rollback state, so when we arrive here the second time, it is possible that some regions have
+   * already been associated with a TRSP.
+   * @param ignoreIfInTransition if true, will skip creating TRSP for the given region if it is
+   *          already in transition, otherwise we will add an assert that it should not in
+   *          transition.
+   */
+  private static TransitRegionStateProcedure[] createRoundRobinAssignProcedures(
+    MasterProcedureEnv env, List<RegionInfo> regions, int regionReplication,
+    List<ServerName> serversToExclude, boolean ignoreIfInTransition) {
+    List<RegionInfo> regionsAndReplicas = new ArrayList<>(regions);
+    if (regionReplication != DEFAULT_REGION_REPLICA) {
+
+      // collect the replica region infos
+      List<RegionInfo> replicaRegionInfos =
+        new ArrayList<RegionInfo>(regions.size() * (regionReplication - 1));
+      for (RegionInfo hri : regions) {
+        // start the index from 1
+        for (int i = 1; i < regionReplication; i++) {
+          replicaRegionInfos.add(RegionReplicaUtil.getRegionInfoForReplica(hri, i));
+        }
+      }
+      regionsAndReplicas.addAll(replicaRegionInfos);
+    }
+    if (ignoreIfInTransition) {
+      for (RegionInfo region : regionsAndReplicas) {
+        if (env.getAssignmentManager().getRegionStates().getOrCreateRegionStateNode(region)
+          .isInTransition()) {
+          return null;
+        }
+      }
+    }
+    // create round robin procs. Note that we exclude the primary region's target server
+    return env.getAssignmentManager()
+      .createRoundRobinAssignProcedures(regionsAndReplicas, serversToExclude);
+  }
+
+  static TransitRegionStateProcedure[] createAssignProceduresForSplitDaughters(
+    MasterProcedureEnv env, List<RegionInfo> daughters, int regionReplication,
+    ServerName parentServer) {
+    if(env.getMasterConfiguration().getBoolean(HConstants.HBASE_ENABLE_SEPARATE_CHILD_REGIONS,
+      false)){
+      // keep daughter one on the parent RS

Review comment:
       s/keep daughter one/keep one daughter/

##########
File path: hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
##########
@@ -156,6 +156,10 @@
   /** Default value for the balancer period */
   public static final int DEFAULT_HBASE_BALANCER_PERIOD = 300000;
 
+  /** Config for support separate child regions */

Review comment:
       I think this config needs more explaination about what it enables. Does it need a default setting too?




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