HBASE-9737 Corrupt HFile cause resource leak leading to Region Server OOM

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1534850 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2013-10-22 23:37:29 +00:00
parent e464f9974f
commit be060b4077
1 changed files with 17 additions and 12 deletions

View File

@ -522,18 +522,23 @@ public class HFile {
boolean isHBaseChecksum = fsdis.shouldUseHBaseChecksum();
assert !isHBaseChecksum; // Initially we must read with FS checksum.
trailer = FixedFileTrailer.readFromStream(fsdis.getStream(isHBaseChecksum), size);
} catch (IllegalArgumentException iae) {
throw new CorruptHFileException("Problem reading HFile Trailer from file " + path, iae);
}
switch (trailer.getMajorVersion()) {
case 2:
return new HFileReaderV2(
path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs);
case 3 :
return new HFileReaderV3(
path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs);
default:
throw new CorruptHFileException("Invalid HFile version " + trailer.getMajorVersion());
switch (trailer.getMajorVersion()) {
case 2:
return new HFileReaderV2(
path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs);
case 3 :
return new HFileReaderV3(
path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs);
default:
throw new IllegalArgumentException("Invalid HFile version " + trailer.getMajorVersion());
}
} catch (Throwable t) {
try {
fsdis.close();
} catch (Throwable t2) {
LOG.warn("Error closing fsdis FSDataInputStreamWrapper", t2);
}
throw new CorruptHFileException("Problem reading HFile Trailer from file " + path, t);
}
}