hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [3/3] hbase git commit: HBASE-15125 HBaseFsck's adoptHdfsOrphan function creates region with wrong end key boundary (chenrongwei)
Date Mon, 25 Jan 2016 03:45:43 GMT
HBASE-15125 HBaseFsck's adoptHdfsOrphan function creates region with wrong end key boundary
(chenrongwei)


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

Branch: refs/heads/hbase-12439
Commit: a87d9560fcf4803bdd7a01b6e4ec21435d4e11b9
Parents: 6ed3c75
Author: tedyu <yuzhihong@gmail.com>
Authored: Sat Jan 23 12:35:57 2016 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Sat Jan 23 12:35:57 2016 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/util/HBaseFsck.java |  5 ++-
 .../hadoop/hbase/util/BaseTestHBaseFsck.java    | 15 ++++++-
 .../hadoop/hbase/util/TestHBaseFsckOneRS.java   |  2 +-
 .../hadoop/hbase/util/TestHBaseFsckTwoRS.java   | 47 ++++++++++++++++++++
 4 files changed, 65 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a87d9560/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
index ca7bc81..bd5ca9d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
@@ -926,8 +926,9 @@ public class HBaseFsck extends Configured implements Closeable {
     LOG.info("Min max keys are : [" + Bytes.toString(orphanRegionRange.getFirst()) + ", "
+
         Bytes.toString(orphanRegionRange.getSecond()) + ")");
 
-    // create new region on hdfs.  move data into place.
-    HRegionInfo hri = new HRegionInfo(template.getTableName(), orphanRegionRange.getFirst(),
orphanRegionRange.getSecond());
+    // create new region on hdfs. move data into place.
+    HRegionInfo hri = new HRegionInfo(template.getTableName(), orphanRegionRange.getFirst(),
+        Bytes.add(orphanRegionRange.getSecond(), new byte[1]));
     LOG.info("Creating new region : " + hri);
     HRegion region = HBaseFsckRepair.createHDFSRegionDir(getConf(), hri, template);
     Path target = region.getRegionFileSystem().getRegionDir();

http://git-wip-us.apache.org/repos/asf/hbase/blob/a87d9560/hbase-server/src/test/java/org/apache/hadoop/hbase/util/BaseTestHBaseFsck.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/BaseTestHBaseFsck.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/BaseTestHBaseFsck.java
index bbb6b53..35560f5 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/BaseTestHBaseFsck.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/BaseTestHBaseFsck.java
@@ -294,7 +294,7 @@ public class BaseTestHBaseFsck {
   }
 
   /**
-   * Counts the number of row to verify data loss or non-dataloss.
+   * Counts the number of rows to verify data loss or non-dataloss.
    */
   int countRows() throws IOException {
      Scan s = new Scan();
@@ -307,6 +307,19 @@ public class BaseTestHBaseFsck {
   }
 
   /**
+   * Counts the number of rows to verify data loss or non-dataloss.
+   */
+  int countRows(byte[] start, byte[] end) throws IOException {
+    Scan s = new Scan(start, end);
+    ResultScanner rs = tbl.getScanner(s);
+    int i = 0;
+    while (rs.next() != null) {
+      i++;
+    }
+    return i;
+  }
+  
+  /**
    * delete table in preparation for next test
    *
    * @param tablename

http://git-wip-us.apache.org/repos/asf/hbase/blob/a87d9560/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
index 1593e6c..c33b2c2 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
@@ -1564,7 +1564,7 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
 
   /**
    * This creates and fixes a bad table with a missing region -- hole in meta
-   * and data present but .regioinfino missing (an orphan hdfs region)in the fs.
+   * and data present but .regioninfo missing (an orphan hdfs region)in the fs.
    */
   @Test(timeout=180000)
   public void testHDFSRegioninfoMissing() throws Exception {

http://git-wip-us.apache.org/repos/asf/hbase/blob/a87d9560/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java
index 17f8637..f3f7e88 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java
@@ -461,4 +461,51 @@ public class TestHBaseFsckTwoRS extends BaseTestHBaseFsck {
     scanner.close();
     meta.close();
   }
+  
+  /**
+   * This creates and fixes a bad table with a missing region -- hole in meta and data present
but
+   * .regioninfo missing (an orphan hdfs region)in the fs. At last we check every row was
present
+   * at the correct region.
+   */
+  @Test(timeout = 180000)
+  public void testHDFSRegioninfoMissingAndCheckRegionBoundary() throws Exception {
+    TableName table = TableName.valueOf("testHDFSRegioninfoMissingAndCheckRegionBoundary");
+    try {
+      setupTable(table);
+      assertEquals(ROWKEYS.length, countRows());
+
+      // Mess it up by leaving a hole in the meta data
+      admin.disableTable(table);
+      deleteRegion(conf, tbl.getTableDescriptor(), Bytes.toBytes("B"), Bytes.toBytes("C"),
true,
+        true, false, true, HRegionInfo.DEFAULT_REPLICA_ID);
+      admin.enableTable(table);
+
+      HBaseFsck hbck = doFsck(conf, false);
+      assertErrors(hbck,
+        new HBaseFsck.ErrorReporter.ERROR_CODE[] {
+            HBaseFsck.ErrorReporter.ERROR_CODE.ORPHAN_HDFS_REGION,
+            HBaseFsck.ErrorReporter.ERROR_CODE.NOT_IN_META_OR_DEPLOYED,
+            HBaseFsck.ErrorReporter.ERROR_CODE.HOLE_IN_REGION_CHAIN });
+      // holes are separate from overlap groups
+      assertEquals(0, hbck.getOverlapGroups(table).size());
+
+      // fix hole
+      doFsck(conf, true);
+
+      // check that hole fixed
+      assertNoErrors(doFsck(conf, false));
+
+      // check data belong to the correct region,every scan should get one row.
+      for (int i = 0; i < ROWKEYS.length; i++) {
+        if (i != ROWKEYS.length - 1) {
+          assertEquals(1, countRows(ROWKEYS[i], ROWKEYS[i + 1]));
+        } else {
+          assertEquals(1, countRows(ROWKEYS[i], null));
+        }
+      }
+
+    } finally {
+      cleanupTable(table);
+    }
+  }
 }


Mime
View raw message