hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmhs...@apache.org
Subject svn commit: r1358956 - in /hbase/branches/0.90: ./ src/main/java/org/apache/hadoop/hbase/util/ src/main/java/org/apache/hadoop/hbase/util/hbck/ src/test/java/org/apache/hadoop/hbase/util/
Date Mon, 09 Jul 2012 07:46:04 GMT
Author: jmhsieh
Date: Mon Jul  9 07:46:03 2012
New Revision: 1358956

URL: http://svn.apache.org/viewvc?rev=1358956&view=rev
Log:
HBASE-4379 [hbck] Does not complain about tables with no end region [Z,] (Anoop Sam John)

Modified:
    hbase/branches/0.90/CHANGES.txt
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/hbck/TableIntegrityErrorHandler.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/hbck/TableIntegrityErrorHandlerImpl.java
    hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1358956&r1=1358955&r2=1358956&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Mon Jul  9 07:46:03 2012
@@ -37,6 +37,7 @@ Release 0.90.7 - Unreleased
    HBASE-6190  TestPriorityCompactionQueue throws NPE 
    HBASE-6200  KeyComparator.compareWithoutRow can be wrong when families have the same prefix
(Jieshan)
    HBASE-5904  Revert HBASE-5155 - is_enabled from shell returns differently breaking compatibility.
(David S. Wang)
+   HBASE-4379  [hbck] Does not complain about tables with no end region [z,] (Anoop Sam John)
 
   IMPROVEMENT
    HBASE-5588  Deprecate/remove AssignmentManager#clearRegionFromTransition

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java?rev=1358956&r1=1358955&r2=1358956&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java Mon Jul
 9 07:46:03 2012
@@ -1697,6 +1697,13 @@ public class HBaseFsck {
             + " create a new region and regioninfo in HDFS to plug the hole.",
             getTableInfo(), hi);
       }
+      
+      @Override
+      public void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException {
+        errors.reportError(ERROR_CODE.LAST_REGION_ENDKEY_NOT_EMPTY,
+            "Last region should end with an empty key. You need to "
+                + "create a new region and regioninfo in HDFS to plug the hole.", getTableInfo());
+      }
 
       @Override
       public void handleDegenerateRegion(HbckInfo hi) throws IOException{
@@ -1780,6 +1787,20 @@ public class HBaseFsck {
         fixes++;
       }
 
+      public void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException {
+        errors.reportError(ERROR_CODE.LAST_REGION_ENDKEY_NOT_EMPTY,
+            "Last region should end with an empty key. Creating a new "
+                + "region and regioninfo in HDFS to plug the hole.", getTableInfo());
+        HTableDescriptor htd = getTableInfo().getHTD();
+        // from curEndKey to EMPTY_START_ROW
+        HRegionInfo newRegion = new HRegionInfo(htd, curEndKey, HConstants.EMPTY_START_ROW);
+
+        HRegion region = HBaseFsckRepair.createHDFSRegionDir(conf, newRegion);
+        LOG.info("Table region end key was not empty. Created new empty region: " + newRegion
+            + " " + region);
+        fixes++;
+      }
+      
       /**
        * There is a hole in the hdfs regions that violates the table integrity
        * rules.  Create a new empty region that patches the hole.
@@ -1948,6 +1969,12 @@ public class HBaseFsck {
      * @return false if there are errors, true if table is clean.
      */
     public boolean checkRegionChain(TableIntegrityErrorHandler handler) throws IOException
{
+      // When table is disabled no need to check for the region chain. Some of the regions
+      // accidently if deployed, this below code might report some issues like missing start
+      // or end regions or region hole in chain and may try to fix which is unwanted.
+      if (disabledTables.contains(this.tableName.getBytes())) {
+        return true;
+      }
       int originalErrorsCount = errors.getErrorList().size();
       Multimap<byte[], HbckInfo> regions = sc.calcCoverage();
       SortedSet<byte[]> splits = sc.getSplits();
@@ -2019,6 +2046,12 @@ public class HBaseFsck {
         prevKey = key;
       }
 
+      // When the last region of a table is proper and having an empty end key, 'prevKey'
+      // will be null.
+      if (prevKey != null) {
+        handler.handleRegionEndKeyNotEmpty(prevKey);
+      }
+      
       for (Collection<HbckInfo> overlap : overlapGroups.asMap().values()) {
         handler.handleOverlapGroup(overlap);
       }
@@ -2552,7 +2585,7 @@ public class HBaseFsck {
       UNKNOWN, NO_META_REGION, NULL_ROOT_REGION, NO_VERSION_FILE, NOT_IN_META_HDFS, NOT_IN_META,
       NOT_IN_META_OR_DEPLOYED, NOT_IN_HDFS_OR_DEPLOYED, NOT_IN_HDFS, SERVER_DOES_NOT_MATCH_META,
NOT_DEPLOYED,
       MULTI_DEPLOYED, SHOULD_NOT_BE_DEPLOYED, MULTI_META_REGION, RS_CONNECT_FAILURE,
-      FIRST_REGION_STARTKEY_NOT_EMPTY, DUPE_STARTKEYS,
+      FIRST_REGION_STARTKEY_NOT_EMPTY, LAST_REGION_ENDKEY_NOT_EMPTY, DUPE_STARTKEYS,
       HOLE_IN_REGION_CHAIN, OVERLAP_IN_REGION_CHAIN, REGION_CYCLE, DEGENERATE_REGION,
       ORPHAN_HDFS_REGION, LINGERING_SPLIT_PARENT
     }
@@ -2560,6 +2593,7 @@ public class HBaseFsck {
     public void report(String message);
     public void reportError(String message);
     public void reportError(ERROR_CODE errorCode, String message);
+    public void reportError(ERROR_CODE errorCode, String message, TableInfo table);
     public void reportError(ERROR_CODE errorCode, String message, TableInfo table, HbckInfo
info);
     public void reportError(ERROR_CODE errorCode, String message, TableInfo table, HbckInfo
info1, HbckInfo info2);
     public int summarize();
@@ -2595,6 +2629,11 @@ public class HBaseFsck {
       showProgress = 0;
     }
 
+    public synchronized void reportError(ERROR_CODE errorCode, String message, TableInfo
table) {
+      errorTables.add(table);
+      reportError(errorCode, message);
+    }
+    
     public synchronized void reportError(ERROR_CODE errorCode, String message, TableInfo
table,
                                          HbckInfo info) {
       errorTables.add(table);

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/hbck/TableIntegrityErrorHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/hbck/TableIntegrityErrorHandler.java?rev=1358956&r1=1358955&r2=1358956&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/hbck/TableIntegrityErrorHandler.java
(original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/hbck/TableIntegrityErrorHandler.java
Mon Jul  9 07:46:03 2012
@@ -48,6 +48,15 @@ public interface TableIntegrityErrorHand
    *    has an empty start key.
    */
   void handleRegionStartKeyNotEmpty(HbckInfo hi) throws IOException;
+  
+  /**
+   * Callback for handling case where a Table has a last region that does not
+   * have an empty end key.
+   *
+   * @param curEndKey The end key of the current last region. There should be a new region
+   *    with start key as this and an empty end key.
+   */
+  void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException;
 
   /**
    * Callback for handling a region that has the same start and end key.

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/hbck/TableIntegrityErrorHandlerImpl.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/hbck/TableIntegrityErrorHandlerImpl.java?rev=1358956&r1=1358955&r2=1358956&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/hbck/TableIntegrityErrorHandlerImpl.java
(original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/hbck/TableIntegrityErrorHandlerImpl.java
Mon Jul  9 07:46:03 2012
@@ -46,6 +46,13 @@ abstract public class TableIntegrityErro
   }
 
   @Override
+  public void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException {
+  }
+  
+  /**
+   * {@inheritDoc}
+   */
+  @Override
   public void handleDegenerateRegion(HbckInfo hi) throws IOException {
   }
 

Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java?rev=1358956&r1=1358955&r2=1358956&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java (original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java Mon
Jul  9 07:46:03 2012
@@ -1016,6 +1016,62 @@ public class TestHBaseFsck {
   }
 
   /**
+   * This creates and fixes a bad table with a missing region which is the 1st region --
hole in
+   * meta and data missing in the fs.
+   */
+  @Test
+  public void testMissingFirstRegion() throws Exception {
+    String table = "testMissingFirstRegion";
+    try {
+      setupTable(table);
+      assertEquals(ROWKEYS.length, countRows());
+
+      // Mess it up by leaving a hole in the assignment, meta, and hdfs data
+      TEST_UTIL.getHBaseAdmin().disableTable(table);
+      deleteRegion(conf, tbl.getTableDescriptor(), Bytes.toBytes(""), Bytes.toBytes("A"),
true,
+          true, true);
+      TEST_UTIL.getHBaseAdmin().enableTable(table);
+
+      HBaseFsck hbck = doFsck(conf, false);
+      assertErrors(hbck, new ERROR_CODE[] { ERROR_CODE.FIRST_REGION_STARTKEY_NOT_EMPTY });
+      // fix hole
+      doFsck(conf, true);
+      // check that hole fixed
+      assertNoErrors(doFsck(conf, false));
+    } finally {
+      deleteTable(table);
+    }
+  }
+  
+  /**
+   * This creates and fixes a bad table with missing last region -- hole in meta and data
missing in
+   * the fs.
+   */
+  @Test
+  public void testMissingLastRegion() throws Exception {
+    String table = "testMissingLastRegion";
+    try {
+      setupTable(table);
+      assertEquals(ROWKEYS.length, countRows());
+
+      // Mess it up by leaving a hole in the assignment, meta, and hdfs data
+      TEST_UTIL.getHBaseAdmin().disableTable(table);
+      deleteRegion(conf, tbl.getTableDescriptor(), Bytes.toBytes("C"), Bytes.toBytes(""),
true,
+          true, true);
+      TEST_UTIL.getHBaseAdmin().enableTable(table);
+
+      HBaseFsck hbck = doFsck(conf, false);
+      assertErrors(hbck, new ERROR_CODE[] { ERROR_CODE.LAST_REGION_ENDKEY_NOT_EMPTY });
+      // fix hole
+      doFsck(conf, true);
+      // check that hole fixed
+      assertNoErrors(doFsck(conf, false));
+    } finally {
+      deleteTable(table);
+    }
+  }
+
+  /**
    * A split parent in meta, in hdfs, and not deployed
    */
   @Test



Mime
View raw message