hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhang...@apache.org
Subject [hbase] branch branch-2.0 updated: HBASE-21795 Client application may get stuck (time bound) if a table modify op is called immediately after split op
Date Mon, 04 Feb 2019 13:04:09 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 0578666  HBASE-21795 Client application may get stuck (time bound) if a table modify
op is called immediately after split op
0578666 is described below

commit 0578666756701506f27521d794d06f451f66a568
Author: Nihal Jain <nihaljain.cs@gmail.com>
AuthorDate: Mon Jan 28 14:05:25 2019 +0530

    HBASE-21795 Client application may get stuck (time bound) if a table modify op is called
immediately after split op
    
    Signed-off-by: zhangduo <zhangduo@apache.org>
---
 .../hbase/master/assignment/AssignmentManager.java |  4 +-
 .../org/apache/hadoop/hbase/client/TestAdmin2.java | 61 ++++++++++++++++++++++
 2 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java
index 00b70d7..d4212f5 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java
@@ -1353,7 +1353,9 @@ public class AssignmentManager implements ServerListener {
     final List<RegionState> states = regionStates.getTableRegionStates(tableName);
     int ritCount = 0;
     for (RegionState regionState: states) {
-      if (!regionState.isOpened()) ritCount++;
+      if (!regionState.isOpened() && !regionState.isSplit()) {
+        ritCount++;
+      }
     }
     return new Pair<Integer, Integer>(ritCount, states.size());
   }
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java
index 4ab1a8f..ad562b2 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java
@@ -46,6 +46,7 @@ import org.apache.hadoop.hbase.TableNotDisabledException;
 import org.apache.hadoop.hbase.TableNotEnabledException;
 import org.apache.hadoop.hbase.TableNotFoundException;
 import org.apache.hadoop.hbase.UnknownRegionException;
+import org.apache.hadoop.hbase.Waiter.Predicate;
 import org.apache.hadoop.hbase.ZooKeeperConnectionException;
 import org.apache.hadoop.hbase.constraint.ConstraintException;
 import org.apache.hadoop.hbase.ipc.HBaseRpcController;
@@ -793,4 +794,64 @@ public class TestAdmin2 {
       Assert.assertEquals(expectedStoreFilesSize, store.getSize());
     }
   }
+
+  @Test
+  public void testTableSplitFollowedByModify() throws Exception {
+    final TableName tableName = TableName.valueOf(name.getMethodName());
+    TEST_UTIL.createTable(tableName, Bytes.toBytes("f"));
+
+    // get the original table region count
+    List<RegionInfo> regions = admin.getRegions(tableName);
+    int originalCount = regions.size();
+    assertEquals(1, originalCount);
+
+    // split the table and wait until region count increases
+    admin.split(tableName, Bytes.toBytes(3));
+    TEST_UTIL.waitFor(30000, new Predicate<Exception>() {
+
+      @Override
+      public boolean evaluate() throws Exception {
+        return admin.getRegions(tableName).size() > originalCount;
+      }
+    });
+
+    // do some table modification
+    TableDescriptor tableDesc = TableDescriptorBuilder.newBuilder(admin.getDescriptor(tableName))
+        .setMaxFileSize(11111111)
+        .build();
+    admin.modifyTable(tableDesc);
+    assertEquals(11111111, admin.getDescriptor(tableName).getMaxFileSize());
+  }
+
+  @Test
+  public void testTableMergeFollowedByModify() throws Exception {
+    final TableName tableName = TableName.valueOf(name.getMethodName());
+    TEST_UTIL.createTable(tableName, new byte[][] { Bytes.toBytes("f") },
+      new byte[][] { Bytes.toBytes(3) });
+
+    // assert we have at least 2 regions in the table
+    List<RegionInfo> regions = admin.getRegions(tableName);
+    int originalCount = regions.size();
+    assertTrue(originalCount >= 2);
+
+    byte[] nameOfRegionA = regions.get(0).getEncodedNameAsBytes();
+    byte[] nameOfRegionB = regions.get(1).getEncodedNameAsBytes();
+
+    // merge the table regions and wait until region count decreases
+    admin.mergeRegionsAsync(nameOfRegionA, nameOfRegionB, true);
+    TEST_UTIL.waitFor(30000, new Predicate<Exception>() {
+
+      @Override
+      public boolean evaluate() throws Exception {
+        return admin.getRegions(tableName).size() < originalCount;
+      }
+    });
+
+    // do some table modification
+    TableDescriptor tableDesc = TableDescriptorBuilder.newBuilder(admin.getDescriptor(tableName))
+        .setMaxFileSize(11111111)
+        .build();
+    admin.modifyTable(tableDesc);
+    assertEquals(11111111, admin.getDescriptor(tableName).getMaxFileSize());
+  }
 }


Mime
View raw message