HBASE-13585 HRegionFileSystem#splitStoreFile() finishes without closing the file handle in some situation (Stephen Yuan Jiang)

This commit is contained in:
Enis Soztutar 2015-04-28 17:27:46 -07:00
parent 3d22c74cb4
commit 7348a05e99
1 changed files with 27 additions and 21 deletions

View File

@ -582,31 +582,37 @@ public class HRegionFileSystem {
if (splitPolicy == null || !splitPolicy.skipStoreFileRangeCheck()) { if (splitPolicy == null || !splitPolicy.skipStoreFileRangeCheck()) {
// Check whether the split row lies in the range of the store file // Check whether the split row lies in the range of the store file
// If it is outside the range, return directly. // If it is outside the range, return directly.
if (top) { try {
//check if larger than last key. if (top) {
KeyValue splitKey = KeyValueUtil.createFirstOnRow(splitRow); //check if larger than last key.
byte[] lastKey = f.createReader().getLastKey(); KeyValue splitKey = KeyValueUtil.createFirstOnRow(splitRow);
// If lastKey is null means storefile is empty. byte[] lastKey = f.createReader().getLastKey();
if (lastKey == null) return null; // If lastKey is null means storefile is empty.
if (f.getReader().getComparator().compareFlatKey(splitKey.getBuffer(), if (lastKey == null) {
splitKey.getKeyOffset(), splitKey.getKeyLength(), lastKey, 0, lastKey.length) > 0) { return null;
return null; }
} if (f.getReader().getComparator().compareFlatKey(splitKey.getBuffer(),
} else { splitKey.getKeyOffset(), splitKey.getKeyLength(), lastKey, 0, lastKey.length) > 0) {
//check if smaller than first key return null;
KeyValue splitKey = KeyValueUtil.createLastOnRow(splitRow); }
byte[] firstKey = f.createReader().getFirstKey(); } else {
// If firstKey is null means storefile is empty. //check if smaller than first key
if (firstKey == null) return null; KeyValue splitKey = KeyValueUtil.createLastOnRow(splitRow);
if (f.getReader().getComparator().compareFlatKey(splitKey.getBuffer(), byte[] firstKey = f.createReader().getFirstKey();
splitKey.getKeyOffset(), splitKey.getKeyLength(), firstKey, 0, firstKey.length) < 0) { // If firstKey is null means storefile is empty.
return null; if (firstKey == null) {
return null;
}
if (f.getReader().getComparator().compareFlatKey(splitKey.getBuffer(),
splitKey.getKeyOffset(), splitKey.getKeyLength(), firstKey, 0, firstKey.length) < 0) {
return null;
}
} }
} finally {
f.closeReader(true);
} }
} }
f.closeReader(true);
Path splitDir = new Path(getSplitsDir(hri), familyName); Path splitDir = new Path(getSplitsDir(hri), familyName);
// A reference to the bottom half of the hsf store file. // A reference to the bottom half of the hsf store file.
Reference r = Reference r =