From 62a942901fc361bdfb12effb75c08859acd46421 Mon Sep 17 00:00:00 2001 From: "terence.yoo" Date: Mon, 13 Jun 2022 17:55:04 +0900 Subject: [PATCH 1/2] fix RIT caused by meta region move during split --- .../ipc/RegionCoprocessorRpcChannel.java | 1 + .../TestSplitTransactionOnCluster.java | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RegionCoprocessorRpcChannel.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RegionCoprocessorRpcChannel.java index f942aedb60c5..3dbb08f5f1f5 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RegionCoprocessorRpcChannel.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RegionCoprocessorRpcChannel.java @@ -90,6 +90,7 @@ protected Message callExecService(RpcController controller, public CoprocessorServiceResponse call(int callTimeout) throws Exception { if (rpcController instanceof HBaseRpcController) { HBaseRpcController hrc = (HBaseRpcController) rpcController; + hrc.reset(); hrc.setPriority(tableName); hrc.setCallTimeout(callTimeout); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java index 2c664933d759..57c4c228641d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java @@ -43,6 +43,7 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Abortable; +import org.apache.hadoop.hbase.ClusterStatus; import org.apache.hadoop.hbase.CoordinatedStateManager; import org.apache.hadoop.hbase.Coprocessor; import org.apache.hadoop.hbase.CoprocessorEnvironment; @@ -1482,6 +1483,53 @@ public boolean evaluate() throws Exception { } } + @Test(timeout = 60000) + public void testMetaRegionMoveDuringSplit() throws Exception { + final TableName tableName = TableName.valueOf("testMetaRegionMoveDuringSplit"); + try { + this.admin.setBalancerRunning(false, true); + + ServerName rs1, rs2, rs3; + ClusterStatus status = TESTING_UTIL.getHBaseClusterInterface().getClusterStatus(); + ArrayList serverNames = new ArrayList<>(status.getServers()); + rs1 = serverNames.get(0); + rs2 = serverNames.get(1); + rs3 = serverNames.get(2); + + // Move meta region to rs1 + admin.move(Bytes.toBytes("1588230740"), Bytes.toBytes(rs1.getServerName())); + TESTING_UTIL.waitUntilNoRegionsInTransition(60000); + + // Create test table + try(Table t = createTableAndWait(tableName, Bytes.toBytes("cf"))) { + insertData(tableName, admin, t); + } + + // Move test table to rs2 that is different from the RS of meta region. This will cause the problem + List regions = cluster.getRegions(tableName); + final HRegionInfo hri = getAndCheckSingleTableRegion(regions); + admin.move(hri.getEncodedNameAsBytes(), Bytes.toBytes(rs2.getServerName())); + TESTING_UTIL.waitUntilNoRegionsInTransition(60000); + + // Find a splittable region + regions = cluster.getRegions(tableName); + final HRegion region = findSplittableRegion(regions); + assertNotNull("not able to find a splittable region", region); + + // Split + this.admin.split(region.getRegionInfo().getRegionName(), new byte[] {42}); + + // Move meta region from rs1 to rs3 during split + this.admin.move(Bytes.toBytes("1588230740"), Bytes.toBytes(rs3.getServerName())); + + LOG.info("Waiting for region to come out of RIT"); + TESTING_UTIL.waitUntilNoRegionsInTransition(60000); + } finally { + admin.setBalancerRunning(true, false); + TESTING_UTIL.deleteTable(tableName); + } + } + public static class MockedCoordinatedStateManager extends ZkCoordinatedStateManager { public void initialize(Server server, HRegion region) { From cdf7613ad58920ec8abefc3eb35e681224c9c24b Mon Sep 17 00:00:00 2001 From: "terence.yoo" Date: Thu, 16 Jun 2022 10:28:31 +0900 Subject: [PATCH 2/2] fix checkstyle violation --- .../hbase/regionserver/TestSplitTransactionOnCluster.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java index 57c4c228641d..3d6e39228e18 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java @@ -1505,7 +1505,8 @@ public void testMetaRegionMoveDuringSplit() throws Exception { insertData(tableName, admin, t); } - // Move test table to rs2 that is different from the RS of meta region. This will cause the problem + // Move test table to rs2 that is different from the RS of meta region. + // This will cause the problem. List regions = cluster.getRegions(tableName); final HRegionInfo hri = getAndCheckSingleTableRegion(regions); admin.move(hri.getEncodedNameAsBytes(), Bytes.toBytes(rs2.getServerName()));