hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-19934 HBaseSnapshotException when read replicas is enabled and online snapshot is taken after region splitting
Date Tue, 06 Feb 2018 19:19:30 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 673e80925 -> 92f733db4


HBASE-19934 HBaseSnapshotException when read replicas is enabled and online snapshot is taken
after region splitting

Signed-off-by: tedyu <yuzhihong@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/92f733db
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/92f733db
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/92f733db

Branch: refs/heads/branch-1
Commit: 92f733db4b25bec5253d4133ae154e3283e74e4e
Parents: 673e809
Author: Toshihiro Suzuki <brfrn169@gmail.com>
Authored: Tue Feb 6 14:51:14 2018 +0900
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Feb 6 11:19:22 2018 -0800

----------------------------------------------------------------------
 .../snapshot/EnabledTableSnapshotHandler.java   |  4 ++-
 .../client/TestRestoreSnapshotFromClient.java   | 26 ++++++++++++--------
 ...oreSnapshotFromClientWithRegionReplicas.java | 26 ++++++++++++++++++++
 3 files changed, 45 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/92f733db/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java
index 81a3bb4..ad5493a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java
@@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.client.RegionReplicaUtil;
 import org.apache.hadoop.hbase.errorhandling.ForeignException;
 import org.apache.hadoop.hbase.master.MasterServices;
 import org.apache.hadoop.hbase.procedure.Procedure;
@@ -98,7 +99,8 @@ public class EnabledTableSnapshotHandler extends TakeSnapshotHandler {
       // Take the offline regions as disabled
       for (Pair<HRegionInfo, ServerName> region : regions) {
         HRegionInfo regionInfo = region.getFirst();
-        if (regionInfo.isOffline() && (regionInfo.isSplit() || regionInfo.isSplitParent()))
{
+        if (regionInfo.isOffline() && (regionInfo.isSplit() || regionInfo.isSplitParent())
&&
+            RegionReplicaUtil.isDefaultReplica(regionInfo)) {
           LOG.info("Take disabled snapshot of offline region=" + regionInfo);
           snapshotDisabledRegion(regionInfo);
         }

http://git-wip-us.apache.org/repos/asf/hbase/blob/92f733db/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java
index b0f07bb..f81cea9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java
@@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.CategoryBasedTimeout;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.TableName;
@@ -59,18 +60,18 @@ public class TestRestoreSnapshotFromClient {
       .withLookingForStuckThread(true)
       .build();
 
-  private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+  protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
 
-  private final byte[] FAMILY = Bytes.toBytes("cf");
+  protected final byte[] FAMILY = Bytes.toBytes("cf");
 
-  private byte[] emptySnapshot;
-  private byte[] snapshotName0;
-  private byte[] snapshotName1;
-  private byte[] snapshotName2;
-  private int snapshot0Rows;
-  private int snapshot1Rows;
-  private TableName tableName;
-  private Admin admin;
+  protected byte[] emptySnapshot;
+  protected byte[] snapshotName0;
+  protected byte[] snapshotName1;
+  protected byte[] snapshotName2;
+  protected int snapshot0Rows;
+  protected int snapshot1Rows;
+  protected TableName tableName;
+  protected Admin admin;
 
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
@@ -299,4 +300,9 @@ public class TestRestoreSnapshotFromClient {
     }
     return families;
   }
+
+  protected void splitRegion(final HRegionInfo regionInfo) throws IOException {
+    byte[][] splitPoints = Bytes.split(regionInfo.getStartKey(), regionInfo.getEndKey(),
1);
+    admin.split(regionInfo.getTable(), splitPoints[1]);
+  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/92f733db/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClientWithRegionReplicas.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClientWithRegionReplicas.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClientWithRegionReplicas.java
index 27ff447..df07a55 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClientWithRegionReplicas.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClientWithRegionReplicas.java
@@ -17,7 +17,14 @@
  */
 package org.apache.hadoop.hbase.client;
 
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 @Category(LargeTests.class)
@@ -27,4 +34,23 @@ public class TestRestoreSnapshotFromClientWithRegionReplicas extends
   protected int getNumReplicas() {
     return 3;
   }
+
+  @Test
+  public void testOnlineSnapshotAfterSplittingRegions() throws IOException, InterruptedException
{
+    List<HRegionInfo> regionInfos = admin.getTableRegions(tableName);
+    RegionReplicaUtil.removeNonDefaultRegions(regionInfos);
+
+    // Split a region
+    splitRegion(regionInfos.get(0));
+
+    // Take a online snapshot
+    admin.snapshot(snapshotName1, tableName);
+
+    // Clone the snapshot to another table
+    TableName clonedTableName = TableName.valueOf("testOnlineSnapshotAfterSplittingRegions-"
+
+        System.currentTimeMillis());
+    admin.cloneSnapshot(snapshotName1, clonedTableName);
+
+    SnapshotTestingUtils.verifyRowCount(TEST_UTIL, clonedTableName, snapshot1Rows);
+  }
 }


Mime
View raw message