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:
parent
e464f9974f
commit
be060b4077
@ -522,18 +522,23 @@ public class HFile {
|
|||||||
boolean isHBaseChecksum = fsdis.shouldUseHBaseChecksum();
|
boolean isHBaseChecksum = fsdis.shouldUseHBaseChecksum();
|
||||||
assert !isHBaseChecksum; // Initially we must read with FS checksum.
|
assert !isHBaseChecksum; // Initially we must read with FS checksum.
|
||||||
trailer = FixedFileTrailer.readFromStream(fsdis.getStream(isHBaseChecksum), size);
|
trailer = FixedFileTrailer.readFromStream(fsdis.getStream(isHBaseChecksum), size);
|
||||||
} catch (IllegalArgumentException iae) {
|
switch (trailer.getMajorVersion()) {
|
||||||
throw new CorruptHFileException("Problem reading HFile Trailer from file " + path, iae);
|
case 2:
|
||||||
}
|
return new HFileReaderV2(
|
||||||
switch (trailer.getMajorVersion()) {
|
path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs);
|
||||||
case 2:
|
case 3 :
|
||||||
return new HFileReaderV2(
|
return new HFileReaderV3(
|
||||||
path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs);
|
path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs);
|
||||||
case 3 :
|
default:
|
||||||
return new HFileReaderV3(
|
throw new IllegalArgumentException("Invalid HFile version " + trailer.getMajorVersion());
|
||||||
path, trailer, fsdis, size, cacheConf, preferredEncodingInCache, hfs);
|
}
|
||||||
default:
|
} catch (Throwable t) {
|
||||||
throw new CorruptHFileException("Invalid HFile version " + trailer.getMajorVersion());
|
try {
|
||||||
|
fsdis.close();
|
||||||
|
} catch (Throwable t2) {
|
||||||
|
LOG.warn("Error closing fsdis FSDataInputStreamWrapper", t2);
|
||||||
|
}
|
||||||
|
throw new CorruptHFileException("Problem reading HFile Trailer from file " + path, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user