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

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


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 2fa6d06  HBASE-22537 Split happened Replica region can not be deleted 
after deleting table successfully and restarting RegionServer
2fa6d06 is described below

commit 2fa6d062f5197ff23cea8c758ec860365f6c8151
Author: sreenivasulureddy <[email protected]>
AuthorDate: Thu Jul 18 15:24:32 2019 +0100

    HBASE-22537 Split happened Replica region can not be deleted after deleting 
table successfully and restarting RegionServer
    
    Signed-off-by: Wellington Chevreuil <[email protected]>
---
 .../hbase/client/TestSplitOrMergeStatus.java       | 73 ++++++++++++++++++++--
 1 file changed, 67 insertions(+), 6 deletions(-)

diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSplitOrMergeStatus.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSplitOrMergeStatus.java
index 11f53a9..f974974 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSplitOrMergeStatus.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSplitOrMergeStatus.java
@@ -27,16 +27,25 @@ import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+
 import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.master.assignment.AssignmentTestingUtil;
+import org.apache.hadoop.hbase.master.assignment.SplitTableRegionProcedure;
+import org.apache.hadoop.hbase.master.procedure.DeleteTableProcedure;
+import org.apache.hadoop.hbase.master.procedure.DisableTableProcedure;
+import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
+import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
+import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Threads;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Ignore;
 import org.junit.Rule;
@@ -60,16 +69,16 @@ public class TestSplitOrMergeStatus {
   /**
    * @throws java.lang.Exception
    */
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {
+  @Before
+  public void setUp() throws Exception {
     TEST_UTIL.startMiniCluster(2);
   }
 
   /**
    * @throws java.lang.Exception
    */
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {
+  @After
+  public void tearDown() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
   }
 
@@ -162,6 +171,58 @@ public class TestSplitOrMergeStatus {
     admin.close();
   }
 
+  @Test
+  public void testSplitRegionReplicaRitRecovery() throws Exception {
+    int startRowNum = 11;
+    int rowCount = 60;
+    final TableName tableName = TableName.valueOf(name.getMethodName());
+    final ProcedureExecutor<MasterProcedureEnv> procExec = 
getMasterProcedureExecutor();
+    
TEST_UTIL.getAdmin().createTable(TableDescriptorBuilder.newBuilder(tableName)
+        
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)).setRegionReplication(2).build());
+    TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
+    ServerName serverName =
+        RegionReplicaTestHelper.getRSCarryingReplica(TEST_UTIL, tableName, 
1).get();
+    List<RegionInfo> regions = TEST_UTIL.getAdmin().getRegions(tableName);
+    insertData(tableName, startRowNum, rowCount);
+    int splitRowNum = startRowNum + rowCount / 2;
+    byte[] splitKey = Bytes.toBytes("" + splitRowNum);
+    // Split region of the table
+    long procId = procExec.submitProcedure(
+      new SplitTableRegionProcedure(procExec.getEnvironment(), regions.get(0), 
splitKey));
+    // Wait the completion
+    ProcedureTestingUtility.waitProcedure(procExec, procId);
+    // Disable the table
+    long procId1 = procExec
+        .submitProcedure(new DisableTableProcedure(procExec.getEnvironment(), 
tableName, false));
+    // Wait the completion
+    ProcedureTestingUtility.waitProcedure(procExec, procId1);
+    // Delete Table
+    long procId2 =
+        procExec.submitProcedure(new 
DeleteTableProcedure(procExec.getEnvironment(), tableName));
+    // Wait the completion
+    ProcedureTestingUtility.waitProcedure(procExec, procId2);
+    AssignmentTestingUtil.killRs(TEST_UTIL, serverName);
+    Threads.sleepWithoutInterrupt(5000);
+    boolean hasRegionsInTransition = 
TEST_UTIL.getMiniHBaseCluster().getMaster()
+        .getAssignmentManager().getRegionStates().hasRegionsInTransition();
+    assertEquals(false, hasRegionsInTransition);
+  }
+
+  private ProcedureExecutor<MasterProcedureEnv> getMasterProcedureExecutor() {
+    return 
TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor();
+  }
+
+  private void insertData(final TableName tableName, int startRow, int 
rowCount)
+      throws IOException {
+    Table t = TEST_UTIL.getConnection().getTable(tableName);
+    Put p;
+    for (int i = 0; i < rowCount; i++) {
+      p = new Put(Bytes.toBytes("" + (startRow + i)));
+      p.addColumn(FAMILY, Bytes.toBytes("q1"), Bytes.toBytes(i));
+      t.put(p);
+    }
+  }
+
   private void initSwitchStatus(Admin admin) throws IOException {
     if (!admin.isSplitOrMergeEnabled(MasterSwitchType.SPLIT)) {
       admin.setSplitOrMergeEnabled(true, false, MasterSwitchType.SPLIT);

Reply via email to