HBASE-19502 Make sure we have closed all StoreFileScanner if we fail to open any StoreFileScanners
This commit is contained in:
parent
536187446d
commit
7f586995a8
|
@ -137,16 +137,26 @@ public class StoreFileScanner implements KeyValueScanner {
|
|||
file.initReader();
|
||||
sortedFiles.add(file);
|
||||
}
|
||||
for (int i = 0, n = files.size(); i < n; i++) {
|
||||
HStoreFile sf = sortedFiles.remove();
|
||||
StoreFileScanner scanner;
|
||||
if (usePread) {
|
||||
scanner = sf.getPreadScanner(cacheBlocks, readPt, i, canOptimizeForNonNullColumn);
|
||||
} else {
|
||||
scanner = sf.getStreamScanner(canUseDrop, cacheBlocks, isCompaction, readPt, i,
|
||||
canOptimizeForNonNullColumn);
|
||||
boolean succ = false;
|
||||
try {
|
||||
for (int i = 0, n = files.size(); i < n; i++) {
|
||||
HStoreFile sf = sortedFiles.remove();
|
||||
StoreFileScanner scanner;
|
||||
if (usePread) {
|
||||
scanner = sf.getPreadScanner(cacheBlocks, readPt, i, canOptimizeForNonNullColumn);
|
||||
} else {
|
||||
scanner = sf.getStreamScanner(canUseDrop, cacheBlocks, isCompaction, readPt, i,
|
||||
canOptimizeForNonNullColumn);
|
||||
}
|
||||
scanners.add(scanner);
|
||||
}
|
||||
succ = true;
|
||||
} finally {
|
||||
if (!succ) {
|
||||
for (StoreFileScanner scanner : scanners) {
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
scanners.add(scanner);
|
||||
}
|
||||
return scanners;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue