HBASE-17118 StoreScanner leaked in KeyValueHeap (binlijin)
This commit is contained in:
parent
b9319496bc
commit
f6fc94ede9
|
@ -26,6 +26,8 @@ import java.util.List;
|
||||||
import java.util.PriorityQueue;
|
import java.util.PriorityQueue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.hbase.Cell;
|
import org.apache.hadoop.hbase.Cell;
|
||||||
import org.apache.hadoop.hbase.CellComparator;
|
import org.apache.hadoop.hbase.CellComparator;
|
||||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||||
|
@ -46,6 +48,7 @@ import org.apache.hadoop.hbase.regionserver.ScannerContext.NextState;
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
|
public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
|
||||||
implements KeyValueScanner, InternalScanner {
|
implements KeyValueScanner, InternalScanner {
|
||||||
|
private static final Log LOG = LogFactory.getLog(KeyValueHeap.class);
|
||||||
protected PriorityQueue<KeyValueScanner> heap = null;
|
protected PriorityQueue<KeyValueScanner> heap = null;
|
||||||
// Holds the scanners when a ever a eager close() happens. All such eagerly closed
|
// Holds the scanners when a ever a eager close() happens. All such eagerly closed
|
||||||
// scans are collected and when the final scanner.close() happens will perform the
|
// scans are collected and when the final scanner.close() happens will perform the
|
||||||
|
@ -292,6 +295,7 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyValueScanner scanner = current;
|
KeyValueScanner scanner = current;
|
||||||
|
try {
|
||||||
while (scanner != null) {
|
while (scanner != null) {
|
||||||
Cell topKey = scanner.peek();
|
Cell topKey = scanner.peek();
|
||||||
if (comparator.getComparator().compare(seekKey, topKey) <= 0) {
|
if (comparator.getComparator().compare(seekKey, topKey) <= 0) {
|
||||||
|
@ -300,8 +304,10 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
|
||||||
// scanners where a lazy-seek operation has been done are not greater
|
// scanners where a lazy-seek operation has been done are not greater
|
||||||
// than their real next keys) but we still need to enforce our
|
// than their real next keys) but we still need to enforce our
|
||||||
// invariant that the top scanner has done a real seek. This way
|
// invariant that the top scanner has done a real seek. This way
|
||||||
// StoreScanner and RegionScanner do not have to worry about fake keys.
|
// StoreScanner and RegionScanner do not have to worry about fake
|
||||||
|
// keys.
|
||||||
heap.add(scanner);
|
heap.add(scanner);
|
||||||
|
scanner = null;
|
||||||
current = pollRealKV();
|
current = pollRealKV();
|
||||||
return current != null;
|
return current != null;
|
||||||
}
|
}
|
||||||
|
@ -311,8 +317,8 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
|
||||||
// If there is only one scanner left, we don't do lazy seek.
|
// If there is only one scanner left, we don't do lazy seek.
|
||||||
seekResult = scanner.requestSeek(seekKey, forward, useBloom);
|
seekResult = scanner.requestSeek(seekKey, forward, useBloom);
|
||||||
} else {
|
} else {
|
||||||
seekResult = NonLazyKeyValueScanner.doRealSeek(
|
seekResult = NonLazyKeyValueScanner.doRealSeek(scanner, seekKey,
|
||||||
scanner, seekKey, forward);
|
forward);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!seekResult) {
|
if (!seekResult) {
|
||||||
|
@ -325,6 +331,16 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
|
||||||
current = null;
|
current = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (scanner != null) {
|
||||||
|
try {
|
||||||
|
scanner.close();
|
||||||
|
} catch (Exception ce) {
|
||||||
|
LOG.warn("close KeyValueScanner error", ce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
// Heap is returning empty, scanner is done
|
// Heap is returning empty, scanner is done
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue