You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2013/10/23 01:45:22 UTC
svn commit: r1534855 -
/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java
Author: stack
Date: Tue Oct 22 23:45:21 2013
New Revision: 1534855
URL: http://svn.apache.org/r1534855
Log:
HBASE-9737 Corrupt HFile cause resource leak leading to Region Server OOM
Modified:
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java?rev=1534855&r1=1534854&r2=1534855&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java Tue Oct 22 23:45:21 2013
@@ -549,19 +549,37 @@ public class HFile {
FixedFileTrailer trailer = null;
try {
trailer = FixedFileTrailer.readFromStream(fsdis, size);
- } catch (IllegalArgumentException iae) {
- throw new CorruptHFileException("Problem reading HFile Trailer from file " + path, iae);
- }
- switch (trailer.getMajorVersion()) {
- case 1:
- return new HFileReaderV1(path, trailer, fsdis, size, closeIStream,
- cacheConf);
- case 2:
- return new HFileReaderV2(path, trailer, fsdis, fsdisNoFsChecksum,
- size, closeIStream,
- cacheConf, preferredEncodingInCache, hfs);
- default:
- throw new CorruptHFileException("Invalid HFile version " + trailer.getMajorVersion());
+ switch (trailer.getMajorVersion()) {
+ case 1:
+ return new HFileReaderV1(path, trailer, fsdis, size, closeIStream,
+ cacheConf);
+ case 2:
+ return new HFileReaderV2(path, trailer, fsdis, fsdisNoFsChecksum,
+ size, closeIStream,
+ cacheConf, preferredEncodingInCache, hfs);
+ default:
+ throw new IllegalArgumentException("Invalid HFile version " + trailer.getMajorVersion());
+ }
+ } catch (Throwable t) {
+ if (closeIStream) {
+ try {
+ if (fsdis != fsdisNoFsChecksum && fsdisNoFsChecksum != null) {
+ fsdisNoFsChecksum.close();
+ fsdisNoFsChecksum = null;
+ }
+ } catch (Throwable t2) {
+ LOG.warn("Error closing fsdisNoFsChecksum FSDataInputStream", t2);
+ }
+ try {
+ if (fsdis != null) {
+ fsdis.close();
+ fsdis = null;
+ }
+ } catch (Throwable t2) {
+ LOG.warn("Error closing fsdis FSDataInputStream", t2);
+ }
+ }
+ throw new CorruptHFileException("Problem reading HFile Trailer from file " + path, t);
}
}