hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From li...@apache.org
Subject svn commit: r1538243 - /hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java
Date Sat, 02 Nov 2013 18:18:20 GMT
Author: liyin
Date: Sat Nov  2 18:18:20 2013
New Revision: 1538243

URL: http://svn.apache.org/r1538243
Log:
[HBASE-2856] [0.89-fb] [trunk version] Clean up the scannerReadPoing if there is an exception.

Author: aaiyer

Summary:
Clean up the scannerReadPoing if there is an exception.
See also https://phabricator.fb.com/D1037580

Test Plan: push to shadow and test

Reviewers: liyintang

Reviewed By: liyintang

CC: hbase-eng@

Differential Revision: https://phabricator.fb.com/D1037582

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java?rev=1538243&r1=1538242&r2=1538243&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java
Sat Nov  2 18:18:20 2013
@@ -102,23 +102,36 @@ public class RegionScanner implements In
 
     // synchronize on scannerReadPoints so that nobody calculates
     // getSmallestReadPoint, before scannerReadPoints is updated.
+    //
+    // TODO: "this" reference is escaping here. Refactor to move this logic
+    // out of constructor into an initialize method
     synchronized(scannerReadPoints) {
       this.readPt = MultiVersionConsistencyControl.resetThreadReadPoint(mvcc);
       scannerReadPoints.put(this, this.readPt);
     }
 
-    List<KeyValueScanner> scanners = new ArrayList<KeyValueScanner>();
-    if (additionalScanners != null) {
-      scanners.addAll(additionalScanners);
-    }
+    try {
+      List<KeyValueScanner> scanners = new ArrayList<KeyValueScanner>();
+      if (additionalScanners != null) {
+        scanners.addAll(additionalScanners);
+      }
 
-    for (Map.Entry<byte[], NavigableSet<byte[]>> entry :
-        scan.getFamilyMap().entrySet()) {
-      Store store = stores.get(entry.getKey());
-      StoreScanner scanner = store.getScanner(scan, entry.getValue());
-      scanners.add(scanner);
+      for (Map.Entry<byte[], NavigableSet<byte[]>> entry :
+          scan.getFamilyMap().entrySet()) {
+        Store store = stores.get(entry.getKey());
+        StoreScanner scanner = store.getScanner(scan, entry.getValue());
+        scanners.add(scanner);
+      }
+      this.storeHeap = new KeyValueHeap(scanners, comparator);
+    } catch (IOException ioe) {
+      LOG.warn("Caught exception while initializing region scanner.", ioe);
+      scannerReadPoints.remove(this);
+      throw ioe;
+    } catch (RuntimeException re) {
+      LOG.warn("Caught exception while initializing region scanner.", re);
+      scannerReadPoints.remove(this);
+      throw re;
     }
-    this.storeHeap = new KeyValueHeap(scanners, comparator);
   }
 
   /**



Mime
View raw message