hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmhs...@apache.org
Subject svn commit: r1463666 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/regionserver/HRegion.java test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java
Date Tue, 02 Apr 2013 18:50:38 GMT
Author: jmhsieh
Date: Tue Apr  2 18:50:37 2013
New Revision: 1463666

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


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

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1463666&r1=1463665&r2=1463666&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Tue
Apr  2 18:50:37 2013
@@ -3577,7 +3577,6 @@ public class HRegion implements HeapSize
           IOException ioe = new DoNotRetryIOException(
               "No such column family " + Bytes.toStringBinary(familyName));
           ioes.add(ioe);
-          failures.add(p);
         } else {
           try {
             store.assertBulkLoadHFileOk(new Path(path));
@@ -3591,6 +3590,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();
@@ -3604,13 +3610,6 @@ public class HRegion implements HeapSize
         return false;
       }
 
-      // validation failed because of some sort of IO problem.
-      if (ioes.size() != 0) {
-        LOG.error("There were IO errors when checking if bulk load is ok.  " +
-            "throwing exception!");
-        throw MultipleIOException.createIOException(ioes);
-      }
-
       for (Pair<byte[], String> p : familyPaths) {
         byte[] familyName = p.getFirst();
         String path = p.getSecond();

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java?rev=1463666&r1=1463665&r2=1463666&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java
Tue Apr  2 18:50:37 2013
@@ -157,6 +157,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.getDataTestDir(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.waitTableAvailable(TABLE, 30000);
+    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();
+  }
+
   @Test
   public void testSplitStoreFile() throws IOException {
     Path dir = util.getDataTestDir("testSplitHFile");



Mime
View raw message