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-15125 HBaseFsck's adoptHdfsOrphan function creates region with wrong end key boundary (chenrongwei)
Date Sat, 23 Jan 2016 20:47:46 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 63f4ba183 -> 889e60f36


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/889e60f3
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/889e60f3
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/889e60f3

Branch: refs/heads/branch-1
Commit: 889e60f36f74ad870a59e37611517547c61f6e90
Parents: 63f4ba1
Author: tedyu <yuzhihong@gmail.com>
Authored: Sat Jan 23 12:47:41 2016 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Sat Jan 23 12:47:41 2016 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/util/HBaseFsck.java |  3 +-
 .../apache/hadoop/hbase/util/TestHBaseFsck.java | 61 +++++++++++++++++++-
 2 files changed, 62 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/889e60f3/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 c8587a2..c5cea1f 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
@@ -932,7 +932,8 @@ public class HBaseFsck extends Configured implements Closeable {
         Bytes.toString(orphanRegionRange.getSecond()) + ")");
 
     // create new region on hdfs.  move data into place.
-    HRegionInfo hri = new HRegionInfo(template.getTableName(), orphanRegionRange.getFirst(),
orphanRegionRange.getSecond());
+    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/889e60f3/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
index 364446a..d008ef4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
@@ -450,7 +450,7 @@ public class TestHBaseFsck {
   }
 
   /**
-   * 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();
@@ -463,6 +463,18 @@ public class TestHBaseFsck {
   }
 
   /**
+   * 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
@@ -1230,6 +1242,53 @@ public class TestHBaseFsck {
   }
 
   /**
+   * 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);
+    }
+  }
+    
+  /**
    * This creates and fixes a bad table with a region that is missing meta and
    * not assigned to a region server.
    */


Mime
View raw message