hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r661089 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/regionserver/HStore.java src/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java
Date Wed, 28 May 2008 21:17:31 GMT
Author: stack
Date: Wed May 28 14:17:31 2008
New Revision: 661089

URL: http://svn.apache.org/viewvc?rev=661089&view=rev
Log:
HBASE-648 If mapfile index is empty, run repair

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=661089&r1=661088&r2=661089&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Wed May 28 14:17:31 2008
@@ -27,6 +27,7 @@
    HBASE-642   Splitting log in a hostile environment -- bad hdfs -- we drop
                write-ahead-log edits
    HBASE-646   EOFException opening HStoreFile info file (spin on HBASE-645and 550)
+   HBASE-648   If mapfile index is empty, run repair
 
   IMPROVEMENTS
    HBASE-559   MR example job to count table rows

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java?rev=661089&r1=661088&r2=661089&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java Wed May 28
14:17:31 2008
@@ -263,29 +263,14 @@
     boolean first = true;
     for(Map.Entry<Long, HStoreFile> e: this.storefiles.entrySet()) {
       MapFile.Reader r = null;
-      try {
-        if (first) {
-          // Use a block cache (if configured) for the first reader only
-          // so as to control memory usage.
-          r = e.getValue().getReader(this.fs, this.bloomFilter,
-            family.isBlockCacheEnabled());
-          first = false;
-        } else {
-          r = e.getValue().getReader(this.fs, this.bloomFilter);
-        }
-      } catch (EOFException eofe) {
-        LOG.warn("Failed open of reader " + e.toString() + "; attempting fix",
-          eofe);
-        try {
-          // Try fixing this file.. if we can.  
-          MapFile.fix(this.fs, e.getValue().getMapFilePath(),
-            HStoreFile.HbaseMapFile.KEY_CLASS,
-            HStoreFile.HbaseMapFile.VALUE_CLASS, false, this.conf);
-        } catch (Exception fixe) {
-          LOG.warn("Failed fix of " + e.toString() +
-            "...continuing; Probable DATA LOSS!!!", fixe);
-          continue;
-        }
+      if (first) {
+        // Use a block cache (if configured) for the first reader only
+        // so as to control memory usage.
+        r = e.getValue().getReader(this.fs, this.bloomFilter,
+          family.isBlockCacheEnabled());
+        first = false;
+      } else {
+        r = e.getValue().getReader(this.fs, this.bloomFilter);
       }
       this.readers.put(e.getKey(), r);
     }
@@ -377,7 +362,8 @@
   /*
    * Creates a series of HStoreFiles loaded from the given directory.
    * There must be a matching 'mapdir' and 'loginfo' pair of files.
-   * If only one exists, we'll delete it.
+   * If only one exists, we'll delete it.  Does other consistency tests
+   * checking files are not zero, etc.
    *
    * @param infodir qualified path for info file directory
    * @param mapdir qualified path for map file directory
@@ -434,7 +420,6 @@
         LOG.info("HSTORE_LOGINFOFILE " + curfile +
           " does not contain a sequence number - ignoring");
       }
-
       Path mapfile = curfile.getMapFilePath();
       if (!fs.exists(mapfile)) {
         fs.delete(curfile.getInfoFilePath(), false);
@@ -449,6 +434,23 @@
           "Deleting.  Continuing...Probable DATA LOSS!!!  See HBASE-646.");
         continue;
       }
+      if (isEmptyIndexFile(mapfile)) {
+        try {
+          // Try fixing this file.. if we can.  Use the hbase version of fix.
+          // Need to remove the old index file first else fix won't go ahead.
+          this.fs.delete(new Path(mapfile, MapFile.INDEX_FILE_NAME));
+          long count = MapFile.fix(this.fs, mapfile, HStoreFile.HbaseMapFile.KEY_CLASS,
+            HStoreFile.HbaseMapFile.VALUE_CLASS, false, this.conf);
+          if (LOG.isDebugEnabled()) {
+            LOG.debug("Fixed index on " + mapfile.toString() + "; had " +
+              count + " entries");
+          }
+        } catch (Exception e) {
+          LOG.warn("Failed fix of " + mapfile.toString() +
+            "...continuing; Probable DATA LOSS!!!", e);
+          continue;
+        }
+      }
       
       // TODO: Confirm referent exists.
       
@@ -486,9 +488,32 @@
   throws IOException {
     // Mapfiles are made of 'data' and 'index' files.  Confirm 'data' is
     // non-null if it exists (may not have been written to yet).
-    Path dataFile = new Path(mapfile, "data");
-    return this.fs.exists(dataFile) &&
-      this.fs.getFileStatus(dataFile).getLen() == 0;
+    return isEmptyFile(new Path(mapfile, MapFile.DATA_FILE_NAME));
+  }
+
+  /* 
+   * @param mapfile
+   * @return True if the passed mapfile has a zero-length index component (its
+   * broken).
+   * @throws IOException
+   */
+  private boolean isEmptyIndexFile(final Path mapfile)
+  throws IOException {
+    // Mapfiles are made of 'data' and 'index' files.  Confirm 'data' is
+    // non-null if it exists (may not have been written to yet).
+    return isEmptyFile(new Path(mapfile, MapFile.INDEX_FILE_NAME));
+  }
+
+  /* 
+   * @param mapfile
+   * @return True if the passed mapfile has a zero-length index component (its
+   * broken).
+   * @throws IOException
+   */
+  private boolean isEmptyFile(final Path f)
+  throws IOException {
+    return this.fs.exists(f) &&
+      this.fs.getFileStatus(f).getLen() == 0;
   }
 
   //////////////////////////////////////////////////////////////////////////////

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java?rev=661089&r1=661088&r2=661089&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java Wed May
28 14:17:31 2008
@@ -622,8 +622,9 @@
    * Hbase customizations of MapFile.
    */
   static class HbaseMapFile extends MapFile {
-    static final Class KEY_CLASS = HStoreKey.class;
-    static final Class VALUE_CLASS = ImmutableBytesWritable.class;
+    static final Class<? extends Writable>  KEY_CLASS = HStoreKey.class;
+    static final Class<? extends Writable>  VALUE_CLASS =
+      ImmutableBytesWritable.class;
 
     /**
      * A reader capable of reading and caching blocks of the data file.
@@ -696,8 +697,6 @@
        * @param conf
        * @param fs
        * @param dirName
-       * @param keyClass
-       * @param valClass
        * @param compression
        * @throws IOException
        */



Mime
View raw message