HBASE-8192 Logic error causes infinite loop in HRegion.bulkLoadHFiles(List) (Chenghao Jiang)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1463664 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Hsieh 2013-04-02 18:50:30 +00:00
parent a12549aa9e
commit b2d42190b2
2 changed files with 50 additions and 8 deletions

View File

@ -3215,7 +3215,6 @@ public class HRegion implements HeapSize { // , Writable{
IOException ioe = new org.apache.hadoop.hbase.exceptions.DoNotRetryIOException( IOException ioe = new org.apache.hadoop.hbase.exceptions.DoNotRetryIOException(
"No such column family " + Bytes.toStringBinary(familyName)); "No such column family " + Bytes.toStringBinary(familyName));
ioes.add(ioe); ioes.add(ioe);
failures.add(p);
} else { } else {
try { try {
store.assertBulkLoadHFileOk(new Path(path)); store.assertBulkLoadHFileOk(new Path(path));
@ -3229,6 +3228,13 @@ public class HRegion implements HeapSize { // , Writable{
} }
} }
// 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. // validation failed, bail out before doing anything permanent.
if (failures.size() != 0) { if (failures.size() != 0) {
StringBuilder list = new StringBuilder(); StringBuilder list = new StringBuilder();
@ -3242,13 +3248,6 @@ public class HRegion implements HeapSize { // , Writable{
return false; 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) { for (Pair<byte[], String> p : familyPaths) {
byte[] familyName = p.getFirst(); byte[] familyName = p.getFirst();
String path = p.getSecond(); String path = p.getSecond();

View File

@ -160,6 +160,49 @@ public class TestLoadIncrementalHFiles {
assertEquals(expectedRows, util.countRows(table)); 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, private void verifyAssignedSequenceNumber(String testName,
byte[][][] hfileRanges, boolean nonZero) throws Exception { byte[][][] hfileRanges, boolean nonZero) throws Exception {
Path dir = util.getDataTestDir(testName); Path dir = util.getDataTestDir(testName);