hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jg...@apache.org
Subject svn commit: r828816 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java src/test/org/apache/hadoop/hbase/regionserver/TestKeyValueHeap.java
Date Thu, 22 Oct 2009 18:53:41 GMT
Author: jgray
Date: Thu Oct 22 18:53:41 2009
New Revision: 828816

URL: http://svn.apache.org/viewvc?rev=828816&view=rev
Log:
HBASE-1927  Scanners not closed properly in certain circumstances

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestKeyValueHeap.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=828816&r1=828815&r2=828816&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Thu Oct 22 18:53:41 2009
@@ -78,6 +78,7 @@
    HBASE-1777  column length is not checked before saved to memstore
    HBASE-1925  IllegalAccessError: Has not been initialized (getMaxSequenceId)
    HBASE-1929  If hbase-default.xml is not in CP, zk session timeout is 10 secs!
+   HBASE-1927  Scanners not closed properly in certain circumstances
 
   IMPROVEMENTS
    HBASE-1760  Cleanup TODOs in HTable

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java?rev=828816&r1=828815&r2=828816&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java Thu
Oct 22 18:53:41 2009
@@ -46,7 +46,8 @@
   private KVScannerComparator comparator;
 
   /**
-   * Constructor
+   * Constructor.  This KeyValueHeap will handle closing of passed in 
+   * KeyValueScanners.
    * @param scanners
    * @param comparator
    */
@@ -57,6 +58,8 @@
     for (KeyValueScanner scanner : scanners) {
       if (scanner.peek() != null) {
         this.heap.add(scanner);
+      } else {
+        scanner.close();
       }
     }
     this.current = heap.poll();

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestKeyValueHeap.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestKeyValueHeap.java?rev=828816&r1=828815&r2=828816&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestKeyValueHeap.java
(original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestKeyValueHeap.java
Thu Oct 22 18:53:41 2009
@@ -154,9 +154,46 @@
     
   }
 
+  public void testScannerLeak() {
+    // Test for unclosed scanners (HBASE-1927)
+    
+    List<KeyValue> l1 = new ArrayList<KeyValue>();
+    l1.add(new KeyValue(row1, fam1, col5, data));
+    l1.add(new KeyValue(row2, fam1, col1, data));
+    l1.add(new KeyValue(row2, fam1, col2, data));
+    scanners.add(new Scanner(l1));
+
+    List<KeyValue> l2 = new ArrayList<KeyValue>();
+    l2.add(new KeyValue(row1, fam1, col1, data));
+    l2.add(new KeyValue(row1, fam1, col2, data));
+    scanners.add(new Scanner(l2));
+
+    List<KeyValue> l3 = new ArrayList<KeyValue>();
+    l3.add(new KeyValue(row1, fam1, col3, data));
+    l3.add(new KeyValue(row1, fam1, col4, data));
+    l3.add(new KeyValue(row1, fam2, col1, data));
+    l3.add(new KeyValue(row1, fam2, col2, data));
+    l3.add(new KeyValue(row2, fam1, col3, data));
+    scanners.add(new Scanner(l3));
+    
+    List<KeyValue> l4 = new ArrayList<KeyValue>();
+    scanners.add(new Scanner(l4));
+
+    //Creating KeyValueHeap
+    KeyValueHeap kvh =
+      new KeyValueHeap(scanners.toArray(new Scanner[0]), KeyValue.COMPARATOR);
+    
+    while(kvh.next() != null);
+    
+    for(Scanner scanner : scanners) {
+      assertTrue(scanner.isClosed());
+    }
+  }
+  
   private static class Scanner implements KeyValueScanner {
     private Iterator<KeyValue> iter;
     private KeyValue current;
+    private boolean closed = false;
 
     public Scanner(List<KeyValue> list) {
       Collections.sort(list, KeyValue.COMPARATOR);
@@ -180,7 +217,13 @@
       return oldCurrent;
     }
 
-    public void close(){}
+    public void close(){
+      closed = true;
+    }
+    
+    public boolean isClosed() {
+      return closed;
+    }
     
     public boolean seek(KeyValue seekKv) {
       while(iter.hasNext()){



Mime
View raw message