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..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 @@ -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,54 @@ 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) {