hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1584383 - in /hbase/trunk: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java src/main/docbkx/book.xml
Date Thu, 03 Apr 2014 20:29:30 GMT
Author: sershe
Date: Thu Apr  3 20:29:30 2014
New Revision: 1584383

URL: http://svn.apache.org/r1584383
Log:
HBASE-10118 Major compact keeps deletes with future timestamps (Liu Shaohui)

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
    hbase/trunk/src/main/docbkx/book.xml

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java?rev=1584383&r1=1584382&r2=1584383&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
Thu Apr  3 20:29:30 2014
@@ -336,9 +336,12 @@ public class ScanQueryMatcher {
         }
         // Can't early out now, because DelFam come before any other keys
       }
-      if (retainDeletesInOutput
-          || (!isUserScan && (EnvironmentEdgeManager.currentTimeMillis() - timestamp)
<= timeToPurgeDeletes)
-          || kv.getMvccVersion() > maxReadPointToTrackVersions) {
+     
+      if ((!isUserScan)
+          && timeToPurgeDeletes > 0
+          && (EnvironmentEdgeManager.currentTimeMillis() - timestamp) <= timeToPurgeDeletes)
{
+        return MatchCode.INCLUDE;
+      } else if (retainDeletesInOutput || kv.getMvccVersion() > maxReadPointToTrackVersions)
{
         // always include or it is not time yet to check whether it is OK
         // to purge deltes or not
         if (!isUserScan) {

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java?rev=1584383&r1=1584382&r2=1584383&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
Thu Apr  3 20:29:30 2014
@@ -62,6 +62,7 @@ import org.apache.hadoop.hbase.LargeTest
 import org.apache.hadoop.hbase.MiniHBaseCluster;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.Waiter;
 import org.apache.hadoop.hbase.client.metrics.ScanMetrics;
 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
 import org.apache.hadoop.hbase.coprocessor.MultiRowMutationEndpoint;
@@ -83,6 +84,7 @@ import org.apache.hadoop.hbase.ipc.Copro
 import org.apache.hadoop.hbase.ipc.RpcClient;
 import org.apache.hadoop.hbase.ipc.RpcServer;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.protobuf.generated.AdminProtos;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType;
 import org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MultiRowMutationService;
@@ -227,6 +229,65 @@ public class TestFromClientSide {
      h.close();
    }
 
+    /**
+    * Basic client side validation of HBASE-10118
+    */
+   @Test
+   public void testPurgeFutureDeletes() throws Exception {
+     final byte[] TABLENAME = Bytes.toBytes("testPurgeFutureDeletes");
+     final byte[] ROW = Bytes.toBytes("row");
+     final byte[] FAMILY = Bytes.toBytes("family");
+     final byte[] COLUMN = Bytes.toBytes("column");
+     final byte[] VALUE = Bytes.toBytes("value");
+
+     HTable table = TEST_UTIL.createTable(TABLENAME, FAMILY);
+
+     // future timestamp
+     long ts = System.currentTimeMillis() * 2;
+     Put put = new Put(ROW, ts);
+     put.add(FAMILY, COLUMN, VALUE);
+     table.put(put);
+
+     Get get = new Get(ROW);
+     Result result = table.get(get);
+     assertArrayEquals(VALUE, result.getValue(FAMILY, COLUMN));
+
+     Delete del = new Delete(ROW);
+     del.deleteColumn(FAMILY, COLUMN, ts);
+     table.delete(del);
+
+     get = new Get(ROW);
+     result = table.get(get);
+     assertNull(result.getValue(FAMILY, COLUMN));
+
+     // major compaction, purged future deletes 
+     TEST_UTIL.getHBaseAdmin().flush(TABLENAME);
+     TEST_UTIL.getHBaseAdmin().majorCompact(TABLENAME);
+
+     // waiting for the major compaction to complete
+     TEST_UTIL.waitFor(6000, new Waiter.Predicate<IOException>() {
+       @Override
+       public boolean evaluate() throws IOException {
+         try {
+           return TEST_UTIL.getHBaseAdmin().getCompactionState(TABLENAME) ==
+               AdminProtos.GetRegionInfoResponse.CompactionState.NONE;
+         } catch (InterruptedException e) {
+           throw new IOException(e);
+         }
+       }
+     });
+
+     put = new Put(ROW, ts);
+     put.add(FAMILY, COLUMN, VALUE);
+     table.put(put);
+
+     get = new Get(ROW);
+     result = table.get(get);
+     assertArrayEquals(VALUE, result.getValue(FAMILY, COLUMN));
+     
+     table.close();
+   }
+
    @Test
    public void testSharedZooKeeper() throws Exception {
      Configuration newConfig = new Configuration(TEST_UTIL.getConfiguration());

Modified: hbase/trunk/src/main/docbkx/book.xml
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/docbkx/book.xml?rev=1584383&r1=1584382&r2=1584383&view=diff
==============================================================================
Binary files - no diff available.



Mime
View raw message