hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raw...@apache.org
Subject svn commit: r936120 - in /hadoop/hbase/branches/0.20: ./ src/java/org/apache/hadoop/hbase/regionserver/ src/test/org/apache/hadoop/hbase/ src/test/org/apache/hadoop/hbase/regionserver/
Date Wed, 21 Apr 2010 00:15:54 GMT
Author: rawson
Date: Wed Apr 21 00:15:54 2010
New Revision: 936120

URL: http://svn.apache.org/viewvc?rev=936120&view=rev
Log:
HBASE-2474  Bug in 2248 - mixed version reads (not allowed by spec)

Modified:
    hadoop/hbase/branches/0.20/CHANGES.txt
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/HBaseTestCase.java
    hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java
    hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/regionserver/TestMemStore.java

Modified: hadoop/hbase/branches/0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/CHANGES.txt?rev=936120&r1=936119&r2=936120&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20/CHANGES.txt Wed Apr 21 00:15:54 2010
@@ -93,6 +93,7 @@ Release 0.20.4 - Unreleased
                (Todd Lipcon via Stack)
    HBASE-2443  IPC client can throw NPE if socket creation fails
                (Todd Lipcon via Stack)
+   HBASE-2474  Bug in 2248 - mixed version reads (not allowed by spec)
 
   IMPROVEMENTS
    HBASE-2180  Bad read performance from synchronizing hfile.fddatainputstream

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=936120&r1=936119&r2=936120&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
(original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
Wed Apr 21 00:15:54 2010
@@ -1181,7 +1181,7 @@ public class HRegion implements HConstan
   throws IOException {
    return getScanner(scan, null);
   }
-  
+
   protected InternalScanner getScanner(Scan scan, List<KeyValueScanner> additionalScanners)
throws IOException {
     newScannerLock.readLock().lock();
     try {
@@ -1915,18 +1915,18 @@ public class HRegion implements HConstan
    * It is used to combine scanners from multiple Stores (aka column families).
    */
   class RegionScanner implements InternalScanner {
-    private final KeyValueHeap storeHeap;
+    private KeyValueHeap storeHeap = null;
     private final byte [] stopRow;
     private Filter filter;
     private RowFilterInterface oldFilter;
     private List<KeyValue> results = new ArrayList<KeyValue>();
     private int isScan;
     private int batch;
+    private Scan theScan = null;
+    private List<KeyValueScanner> extraScanners = null;
 
     RegionScanner(Scan scan, List<KeyValueScanner> additionalScanners) {
-      ReadWriteConsistencyControl.resetThreadReadPoint(rwcc);
-
-      //DebugPrint.println("HRegionScanner.<init>, threadpoint = " + ReadWriteConsistencyControl.getThreadReadPoint());
+      //DebugPrint.println("HRegionScanner.<init>");
       this.filter = scan.getFilter();
       this.batch = scan.getBatch();
       this.oldFilter = scan.getOldFilter();
@@ -1936,23 +1936,29 @@ public class HRegion implements HConstan
         this.stopRow = scan.getStopRow();
       }
       this.isScan = scan.isGetScan() ? -1 : 0;
-      
+      this.theScan = scan;
+      this.extraScanners = additionalScanners;
+    }
+
+    RegionScanner(Scan scan) {
+      this(scan, null);
+    }
+
+    void initHeap() {
       List<KeyValueScanner> scanners = new ArrayList<KeyValueScanner>();
-      if (additionalScanners != null) {
-        scanners.addAll(additionalScanners);
+      if (extraScanners != null) {
+        scanners.addAll(extraScanners);
       }
+
       for (Map.Entry<byte[], NavigableSet<byte[]>> entry :
-          scan.getFamilyMap().entrySet()) {
+          theScan.getFamilyMap().entrySet()) {
         Store store = stores.get(entry.getKey());
-        scanners.add(store.getScanner(scan, entry.getValue()));
+        scanners.add(store.getScanner(theScan, entry.getValue()));
       }
-      this.storeHeap = 
+      this.storeHeap =
         new KeyValueHeap(scanners.toArray(new KeyValueScanner[0]), comparator);
     }
-    
-    RegionScanner(Scan scan) {
-      this(scan, null);
-    }
+
 
     /**
      * Reset both the filter and the old filter.
@@ -1978,6 +1984,11 @@ public class HRegion implements HConstan
 
       // This could be a new thread from the last time we called next().
       ReadWriteConsistencyControl.resetThreadReadPoint(rwcc);
+      // lazy init the store heap.
+      if (storeHeap == null) {
+        initHeap();
+      }
+
       results.clear();
       boolean returnResult = nextInternal(limit);
       if (!returnResult && filterRow()) {

Modified: hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/HBaseTestCase.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/HBaseTestCase.java?rev=936120&r1=936119&r2=936120&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/HBaseTestCase.java (original)
+++ hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/HBaseTestCase.java Wed Apr
21 00:15:54 2010
@@ -666,4 +666,14 @@ public abstract class HBaseTestCase exte
       Bytes.toString(actual) + ">");
     }
   }
+
+  public static void assertEquals(byte[] expected,
+                               byte[] actual) {
+    if (Bytes.compareTo(expected, actual) != 0) {
+      throw new AssertionFailedError("expected:<" +
+      Bytes.toStringBinary(expected) + "> but was:<" +
+      Bytes.toStringBinary(actual) + ">");
+    }
+  }
+
 }

Modified: hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=936120&r1=936119&r2=936120&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java
(original)
+++ hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Wed Apr 21 00:15:54 2010
@@ -1000,6 +1000,7 @@ public class TestHRegion extends HBaseTe
     String method = this.getName();
     initHRegion(tableName, method, families);
     
+
     //Putting data in Region
     Put put = new Put(row1);
     put.add(fam1, null, null);
@@ -1009,18 +1010,20 @@ public class TestHRegion extends HBaseTe
     region.put(put);
     
     Scan scan = null;
-    InternalScanner is = null;
+    HRegion.RegionScanner is = null;
     
     //Testing to see how many scanners that is produced by getScanner, starting 
     //with known number, 2 - current = 1
     scan = new Scan();
     scan.addFamily(fam2);
     scan.addFamily(fam4);
-    is = region.getScanner(scan);
+    is = (RegionScanner) region.getScanner(scan);
+    is.initHeap(); // i dont like this test
     assertEquals(1, ((RegionScanner)is).getStoreHeap().getHeap().size());
     
     scan = new Scan();
-    is = region.getScanner(scan);
+    is = (RegionScanner) region.getScanner(scan);
+    is.initHeap();
     assertEquals(families.length -1, 
         ((RegionScanner)is).getStoreHeap().getHeap().size());
   }
@@ -2114,7 +2117,7 @@ public class TestHRegion extends HBaseTe
   public void testWritesWhileGetting()
     throws IOException, InterruptedException {
     byte[] tableName = Bytes.toBytes("testWritesWhileScanning");
-    int testCount = 200;
+    int testCount = 100;
     int numRows = 1;
     int numFamilies = 10;
     int numQualifiers = 100;
@@ -2161,6 +2164,15 @@ public class TestHRegion extends HBaseTe
           result.getCellValue(families[0], qualifiers[0]).getTimestamp();
         Assert.assertTrue(timestamp >= prevTimestamp);
         prevTimestamp = timestamp;
+
+        byte [] gotValue = null;
+        for (KeyValue kv : result.raw()) {
+          byte [] thisValue = kv.getValue();
+          if (gotValue != null) {
+            assertEquals(gotValue, thisValue);
+          }
+          gotValue = thisValue;
+        }
       }
     }
 

Modified: hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/regionserver/TestMemStore.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/regionserver/TestMemStore.java?rev=936120&r1=936119&r2=936120&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/regionserver/TestMemStore.java
(original)
+++ hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/regionserver/TestMemStore.java
Wed Apr 21 00:15:54 2010
@@ -297,6 +297,7 @@ public class TestMemStore extends TestCa
         rwcc.completeMemstoreInsert(w);
 
         // Assert that we can read back
+        ReadWriteConsistencyControl.resetThreadReadPoint(rwcc);
 
         KeyValueScanner s = this.memstore.getScanners()[0];
         s.seek(kv);
@@ -309,7 +310,7 @@ public class TestMemStore extends TestCa
     }
   }
 
-  public void no_testReadOwnWritesUnderConcurrency() throws Throwable {
+  public void testReadOwnWritesUnderConcurrency() throws Throwable {
 
     int NUM_THREADS = 8;
 



Mime
View raw message