hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mbau...@apache.org
Subject svn commit: r1336810 - in /hbase/branches/0.89-fb/src: main/java/org/apache/hadoop/hbase/regionserver/ test/java/org/apache/hadoop/hbase/regionserver/
Date Thu, 10 May 2012 17:40:42 GMT
Author: mbautin
Date: Thu May 10 17:40:42 2012
New Revision: 1336810

URL: http://svn.apache.org/viewvc?rev=1336810&view=rev
Log:
[89-int] [HBASE-5579] Pull HBASE-5579 : A Delete Version could mask other values

Author: aaiyer

Summary:
 Fix issues with using TS=0 as a sentinel value in the ScanDeleteTracker.

Description:
Currently, Timestamp 0 is  used by the deleteTracker to indicate that there are no active
deletes in the DeleteTracker.

This is wrong because timestamp 0 is a valid timestamp. Bugs include:

  (ii) KV(ts=0) gets deleted whenever there is any deleteVersion (ts>0).
  (i) deleteColumn(0) gets ignored because the ScanDeleteTracker is indistinguishable from
the state where there were no deletes..

Test Plan:
pulling in from open source. Testing with MR unit tests.

some tests failed, reran them locally. Only test that still fails:

TestRegionStateOnMasterFailure

Reviewers: kannan, kranganathan

Reviewed By: kannan

CC: nzhang, hbase-eng@

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

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/ScanDeleteTracker.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompaction.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanDeleteTracker.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/ScanDeleteTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/ScanDeleteTracker.java?rev=1336810&r1=1336809&r2=1336810&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/ScanDeleteTracker.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/ScanDeleteTracker.java
Thu May 10 17:40:42 2012
@@ -21,7 +21,6 @@
 package org.apache.hadoop.hbase.regionserver;
 
 import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.regionserver.DeleteTracker.DeleteResult;
 import org.apache.hadoop.hbase.util.Bytes;
 
 /**
@@ -41,7 +40,8 @@ import org.apache.hadoop.hbase.util.Byte
  */
 public class ScanDeleteTracker implements DeleteTracker {
 
-  private long familyStamp = -1L;
+  private boolean hasFamilyStamp = false;
+  private long familyStamp = 0L;
   private byte [] deleteBuffer = null;
   private int deleteOffset = 0;
   private int deleteLength = 0;
@@ -69,8 +69,9 @@ public class ScanDeleteTracker implement
   @Override
   public void add(byte[] buffer, int qualifierOffset, int qualifierLength,
       long timestamp, byte type) {
-    if (timestamp > familyStamp) {
+    if (!hasFamilyStamp || timestamp > familyStamp) {
       if (type == KeyValue.Type.DeleteFamily.getCode()) {
+        hasFamilyStamp = true;
         familyStamp = timestamp;
         return;
       }
@@ -105,7 +106,7 @@ public class ScanDeleteTracker implement
   @Override
   public DeleteResult isDeleted(byte [] buffer, int qualifierOffset,
       int qualifierLength, long timestamp) {
-    if (timestamp <= familyStamp) {
+    if (hasFamilyStamp && timestamp <= familyStamp) {
       return DeleteResult.FAMILY_DELETED;
     }
 
@@ -144,12 +145,13 @@ public class ScanDeleteTracker implement
 
   @Override
   public boolean isEmpty() {
-    return deleteBuffer == null && familyStamp == 0;
+    return deleteBuffer == null && !hasFamilyStamp;
   }
 
   @Override
   // called between every row.
   public void reset() {
+    hasFamilyStamp = false;
     familyStamp = 0L;
     deleteBuffer = null;
   }
@@ -159,4 +161,4 @@ public class ScanDeleteTracker implement
   public void update() {
     this.reset();
   }
-}
\ No newline at end of file
+}

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompaction.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompaction.java?rev=1336810&r1=1336809&r2=1336810&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompaction.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompaction.java
Thu May 10 17:40:42 2012
@@ -360,11 +360,10 @@ public class TestCompaction extends HBas
     deleteVersion.deleteColumn(fam2, col2, 1);
     /*
      * the table has 4 versions: 0, 1, 2, and 3.
-     * 0 does not count.
      * We delete 1.
-     * Should have 2 remaining.
+     * Should have 3 remaining.
      */
-    testMinorCompactionWithDelete(deleteVersion, 2);
+    testMinorCompactionWithDelete(deleteVersion, 3);
   }
 
   /*
@@ -550,7 +549,7 @@ public class TestCompaction extends HBas
   private void createSmallerStoreFile(final HRegion region) throws IOException {
     HRegionIncommon loader = new HRegionIncommon(region);
     addContent(loader, Bytes.toString(COLUMN_FAMILY), ("" +
-    		"bbb").getBytes(), null);
+        "bbb").getBytes(), null);
     loader.flushcache();
   }
 

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanDeleteTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanDeleteTracker.java?rev=1336810&r1=1336809&r2=1336810&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanDeleteTracker.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanDeleteTracker.java
Thu May 10 17:40:42 2012
@@ -83,6 +83,19 @@ public class TestScanDeleteTracker exten
     assertEquals(DeleteResult.COLUMN_DELETED, ret);
   }
 
+  public void testDelete_KeepVersionZero(){
+    byte [] qualifier = Bytes.toBytes("qualifier");
+    deleteType = KeyValue.Type.Delete.getCode();
+
+    long deleteTimestamp = 10;
+    long valueTimestamp = 0;
+
+    sdt.reset();
+    sdt.add(qualifier, 0, qualifier.length, deleteTimestamp, deleteType);
+    DeleteResult ret = sdt.isDeleted(qualifier, 0, qualifier.length, valueTimestamp);
+    assertEquals(DeleteResult.NOT_DELETED, ret);
+  }
+
 
   public void testDeleteColumn_Delete() {
     byte [] qualifier = Bytes.toBytes("qualifier");



Mime
View raw message