You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2018/12/14 00:14:38 UTC
[10/50] [abbrv] hbase git commit: HBASE-17118 StoreScanner leaked in
KeyValueHeap (binlijin)
HBASE-17118 StoreScanner leaked in KeyValueHeap (binlijin)
HBASE-17118 StoreScanner leaked in KeyValueHeap (addendum)
Amending-Author: Andrew Purtell <ap...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/25135dd0
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/25135dd0
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/25135dd0
Branch: refs/heads/branch-1.3
Commit: 25135dd0a13538e4dd4ffdd34dcb3120a010be3b
Parents: 286ade8
Author: tedyu <yu...@gmail.com>
Authored: Thu Nov 17 08:46:11 2016 -0800
Committer: Andrew Purtell <ap...@apache.org>
Committed: Wed Dec 12 18:08:16 2018 -0800
----------------------------------------------------------------------
.../hadoop/hbase/regionserver/KeyValueHeap.java | 68 ++++++++++++--------
1 file changed, 42 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/25135dd0/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
index ac76bfd..5073c7e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
@@ -24,6 +24,8 @@ import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.KeyValue.KVComparator;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
@@ -44,6 +46,7 @@ import org.apache.hadoop.hbase.regionserver.ScannerContext.NextState;
@InterfaceAudience.Private
public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
implements KeyValueScanner, InternalScanner {
+ private static final Log LOG = LogFactory.getLog(KeyValueHeap.class);
protected PriorityQueue<KeyValueScanner> heap = null;
/**
@@ -289,35 +292,48 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
heap.add(current);
current = null;
- KeyValueScanner scanner;
- while ((scanner = heap.poll()) != null) {
- Cell topKey = scanner.peek();
- if (comparator.getComparator().compare(seekKey, topKey) <= 0) {
- // Top KeyValue is at-or-after Seek KeyValue. We only know that all
- // scanners are at or after seekKey (because fake keys of
- // scanners where a lazy-seek operation has been done are not greater
- // than their real next keys) but we still need to enforce our
- // invariant that the top scanner has done a real seek. This way
- // StoreScanner and RegionScanner do not have to worry about fake keys.
- heap.add(scanner);
- current = pollRealKV();
- return current != null;
- }
+ KeyValueScanner scanner = null;
+ try {
+ while ((scanner = heap.poll()) != null) {
+ Cell topKey = scanner.peek();
+ if (comparator.getComparator().compare(seekKey, topKey) <= 0) {
+ // Top KeyValue is at-or-after Seek KeyValue. We only know that all
+ // scanners are at or after seekKey (because fake keys of
+ // scanners where a lazy-seek operation has been done are not greater
+ // than their real next keys) but we still need to enforce our
+ // invariant that the top scanner has done a real seek. This way
+ // StoreScanner and RegionScanner do not have to worry about fake
+ // keys.
+ heap.add(scanner);
+ scanner = null;
+ current = pollRealKV();
+ return current != null;
+ }
- boolean seekResult;
- if (isLazy && heap.size() > 0) {
- // If there is only one scanner left, we don't do lazy seek.
- seekResult = scanner.requestSeek(seekKey, forward, useBloom);
- } else {
- seekResult = NonLazyKeyValueScanner.doRealSeek(
- scanner, seekKey, forward);
- }
+ boolean seekResult;
+ if (isLazy && heap.size() > 0) {
+ // If there is only one scanner left, we don't do lazy seek.
+ seekResult = scanner.requestSeek(seekKey, forward, useBloom);
+ } else {
+ seekResult = NonLazyKeyValueScanner.doRealSeek(scanner, seekKey,
+ forward);
+ }
- if (!seekResult) {
- scanner.close();
- } else {
- heap.add(scanner);
+ if (!seekResult) {
+ scanner.close();
+ } else {
+ heap.add(scanner);
+ }
+ }
+ } 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