hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1358333 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Date Fri, 06 Jul 2012 18:24:40 GMT
Author: larsh
Date: Fri Jul  6 18:24:39 2012
New Revision: 1358333

URL: http://svn.apache.org/viewvc?rev=1358333&view=rev
Log:
HBASE-6311 Data error after majorCompaction caused by keeping MVCC for opened scanners (chunhui
shen)

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java?rev=1358333&r1=1358332&r2=1358333&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
Fri Jul  6 18:24:39 2012
@@ -291,10 +291,9 @@ public class ScanQueryMatcher {
         }
         // Can't early out now, because DelFam come before any other keys
       }
-      if (retainDeletesInOutput ||
-          (!isUserScan &&
-              (EnvironmentEdgeManager.currentTimeMillis() - timestamp) <= 
-              timeToPurgeDeletes)) {
+      if (retainDeletesInOutput
+          || (!isUserScan && (EnvironmentEdgeManager.currentTimeMillis() - timestamp)
<= timeToPurgeDeletes)
+          || kv.getMemstoreTS() > maxReadPointToTrackVersions) {
         // always include or it is not time yet to check whether it is OK
         // to purge deltes or not
         return MatchCode.INCLUDE;

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=1358333&r1=1358332&r2=1358333&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Fri Jul  6 18:24:39 2012
@@ -151,6 +151,56 @@ public class TestHRegion extends HBaseTe
   // /tmp/testtable
   //////////////////////////////////////////////////////////////////////////////
 
+  public void testCompactionAffectedByScanners() throws Exception {
+    String method = "testCompactionAffectedByScanners";
+    byte[] tableName = Bytes.toBytes(method);
+    byte[] family = Bytes.toBytes("family");
+    Configuration conf = HBaseConfiguration.create();
+    this.region = initHRegion(tableName, method, conf, family);
+
+    Put put = new Put(Bytes.toBytes("r1"));
+    put.add(family, Bytes.toBytes("q1"), Bytes.toBytes("v1"));
+    region.put(put);
+    region.flushcache();
+
+
+    Scan scan = new Scan();
+    scan.setMaxVersions(3);
+    // open the first scanner
+    RegionScanner scanner1 = region.getScanner(scan);
+
+    Delete delete = new Delete(Bytes.toBytes("r1"));
+    region.delete(delete, null, false);
+    region.flushcache();
+
+    // open the second scanner
+    RegionScanner scanner2 = region.getScanner(scan);
+
+    List<KeyValue> results = new ArrayList<KeyValue>();
+
+    System.out.println("Smallest read point:" + region.getSmallestReadPoint());
+
+    // make a major compaction
+    region.compactStores(true);
+
+    // open the third scanner
+    RegionScanner scanner3 = region.getScanner(scan);
+
+    // get data from scanner 1, 2, 3 after major compaction
+    scanner1.next(results);
+    System.out.println(results);
+    assertEquals(1, results.size());
+
+    results.clear();
+    scanner2.next(results);
+    System.out.println(results);
+    assertEquals(0, results.size());
+
+    results.clear();
+    scanner3.next(results);
+    System.out.println(results);
+    assertEquals(0, results.size());
+  }
 
   public void testSkipRecoveredEditsReplay() throws Exception {
     String method = "testSkipRecoveredEditsReplay";



Mime
View raw message