hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chia7...@apache.org
Subject hbase git commit: HBASE-19502 Make sure we have closed all StoreFileScanner if we fail to open any StoreFileScanners
Date Wed, 13 Dec 2017 14:16:10 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 a1ec048d2 -> 54ca1db6b


HBASE-19502 Make sure we have closed all StoreFileScanner if we fail to open any StoreFileScanners


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/54ca1db6
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/54ca1db6
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/54ca1db6

Branch: refs/heads/branch-1
Commit: 54ca1db6bd0b6095fd05b9853e8506d6dadc5d23
Parents: a1ec048
Author: Chia-Ping Tsai <chia7712@gmail.com>
Authored: Wed Dec 13 21:47:27 2017 +0800
Committer: Chia-Ping Tsai <chia7712@gmail.com>
Committed: Wed Dec 13 21:47:27 2017 +0800

----------------------------------------------------------------------
 .../hbase/regionserver/StoreFileScanner.java    | 22 ++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/54ca1db6/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
index 8132365..b3f7fa6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
@@ -132,12 +132,22 @@ public class StoreFileScanner implements KeyValueScanner {
     List<StoreFileScanner> scanners = new ArrayList<StoreFileScanner>(files.size());
     List<StoreFile> sorted_files = new ArrayList<>(files);
     Collections.sort(sorted_files, StoreFile.Comparators.SEQ_ID);
-    for (int i = 0; i < sorted_files.size(); i++) {
-      StoreFile.Reader r = sorted_files.get(i).createReader(canUseDrop);
-      r.setReplicaStoreFile(isPrimaryReplica);
-      StoreFileScanner scanner = r.getStoreFileScanner(cacheBlocks, usePread, isCompaction,
readPt,
-        i, matcher != null ? !matcher.hasNullColumnInQuery() : false);
-      scanners.add(scanner);
+    boolean succ = false;
+    try {
+      for (int i = 0; i < sorted_files.size(); i++) {
+        StoreFile.Reader r = sorted_files.get(i).createReader(canUseDrop);
+        r.setReplicaStoreFile(isPrimaryReplica);
+        StoreFileScanner scanner = r.getStoreFileScanner(cacheBlocks, usePread, isCompaction,
readPt,
+            i, matcher != null ? !matcher.hasNullColumnInQuery() : false);
+        scanners.add(scanner);
+      }
+      succ = true;
+    } finally {
+      if (!succ) {
+        for (StoreFileScanner scanner : scanners) {
+          scanner.close();
+        }
+      }
     }
     return scanners;
   }


Mime
View raw message