You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jm...@apache.org on 2013/04/02 20:50:35 UTC

svn commit: r1463665 - in /hbase/branches/0.95/hbase-server/src: main/java/org/apache/hadoop/hbase/regionserver/HRegion.java test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java

Author: jmhsieh
Date: Tue Apr  2 18:50:34 2013
New Revision: 1463665

URL: http://svn.apache.org/r1463665
Log:
HBASE-8192 Logic error causes infinite loop in HRegion.bulkLoadHFiles(List) (Chenghao Jiang)


Modified:
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1463665&r1=1463664&r2=1463665&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Tue Apr  2 18:50:34 2013
@@ -3264,7 +3264,6 @@ public class HRegion implements HeapSize
           IOException ioe = new org.apache.hadoop.hbase.exceptions.DoNotRetryIOException(
               "No such column family " + Bytes.toStringBinary(familyName));
           ioes.add(ioe);
-          failures.add(p);
         } else {
           try {
             store.assertBulkLoadHFileOk(new Path(path));
@@ -3278,6 +3277,13 @@ public class HRegion implements HeapSize
         }
       }
 
+      // validation failed because of some sort of IO problem.
+      if (ioes.size() != 0) {
+        IOException e = MultipleIOException.createIOException(ioes);
+        LOG.error("There were one or more IO errors when checking if the bulk load is ok.", e);
+        throw e;
+      }
+
       // validation failed, bail out before doing anything permanent.
       if (failures.size() != 0) {
         StringBuilder list = new StringBuilder();
@@ -3291,13 +3297,6 @@ public class HRegion implements HeapSize
         return false;
       }
 
-      // validation failed because of some sort of IO problem.
-      if (ioes.size() != 0) {
-        IOException e = MultipleIOException.createIOException(ioes);
-        LOG.error("There were one or more IO errors when checking if the bulk load is ok.", e);
-        throw e;
-      }
-
       for (Pair<byte[], String> p : familyPaths) {
         byte[] familyName = p.getFirst();
         String path = p.getSecond();

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java?rev=1463665&r1=1463664&r2=1463665&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java Tue Apr  2 18:50:34 2013
@@ -160,6 +160,49 @@ public class TestLoadIncrementalHFiles {
     assertEquals(expectedRows, util.countRows(table));
   }
 
+  /**
+   * Test loading into a column family that does not exist.
+   */
+  @Test
+  public void testNonexistentColumnFamilyLoad() throws Exception {
+    String testName = "testNonexistentColumnFamilyLoad";
+    byte[][][] hfileRanges = new byte[][][] {
+      new byte[][]{ Bytes.toBytes("aaa"), Bytes.toBytes("ccc") },
+      new byte[][]{ Bytes.toBytes("ddd"), Bytes.toBytes("ooo") },
+    }; 
+
+    Path dir = util.getDataTestDirOnTestFS(testName);
+    FileSystem fs = util.getTestFileSystem();
+    dir = dir.makeQualified(fs);
+    Path familyDir = new Path(dir, Bytes.toString(FAMILY));
+
+    int hfileIdx = 0;
+    for (byte[][] range : hfileRanges) {
+      byte[] from = range[0];
+      byte[] to = range[1];
+      createHFile(util.getConfiguration(), fs, new Path(familyDir, "hfile_"
+          + hfileIdx++), FAMILY, QUALIFIER, from, to, 1000);
+    }
+
+    final byte[] TABLE = Bytes.toBytes("mytable_"+testName);
+
+    HBaseAdmin admin = new HBaseAdmin(util.getConfiguration());
+    HTableDescriptor htd = new HTableDescriptor(TABLE);
+    admin.createTable(htd, SPLIT_KEYS);
+
+    HTable table = new HTable(util.getConfiguration(), TABLE);
+    util.waitTableEnabled(TABLE);
+    LoadIncrementalHFiles loader = new LoadIncrementalHFiles(util.getConfiguration(), false);
+    try {
+      loader.doBulkLoad(dir, table);
+      assertTrue("Loading into table with non-existent family should have failed", false);
+    } catch (Exception e) {
+      assertTrue("IOException expected", e instanceof IOException);
+    }
+    table.close();
+    admin.close();
+  }
+
   private void verifyAssignedSequenceNumber(String testName,
       byte[][][] hfileRanges, boolean nonZero) throws Exception {
     Path dir = util.getDataTestDir(testName);