cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [1/5] git commit: Track expired tombstones
Date Wed, 27 Aug 2014 11:12:24 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 14dbba9d1 -> f18108d81


Track expired tombstones

Patch by marcuse; reviewed by slebresne for CASSANDRA-7810


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7f9e9a87
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7f9e9a87
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7f9e9a87

Branch: refs/heads/trunk
Commit: 7f9e9a87188ccbc16bbb1630fe0720d6b366569d
Parents: 1cf9863
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Tue Aug 26 14:16:48 2014 +0200
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Wed Aug 27 12:55:17 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/cassandra/db/ColumnIndex.java    |  2 +-
 .../org/apache/cassandra/db/RangeTombstone.java |  8 +++++-
 .../db/compaction/LazilyCompactedRow.java       |  3 ++-
 .../apache/cassandra/db/RangeTombstoneTest.java | 27 ++++++++++++++++++++
 5 files changed, 38 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7f9e9a87/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index badb45e..d27be1f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.2.19
+ * Track expired tombstones (CASSANDRA-7810)
  * Validate empty cell names from counter updates (CASSANDRA-7798)
  * Improve PasswordAuthenticator default super user setup (CASSANDRA-7788)
  * Remove duplicates from StorageService.getJoiningNodes (CASSANDRA-7478)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7f9e9a87/src/java/org/apache/cassandra/db/ColumnIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnIndex.java b/src/java/org/apache/cassandra/db/ColumnIndex.java
index b152f30..284def5 100644
--- a/src/java/org/apache/cassandra/db/ColumnIndex.java
+++ b/src/java/org/apache/cassandra/db/ColumnIndex.java
@@ -187,7 +187,7 @@ public class ColumnIndex
 
             // TODO: Should deal with removing unneeded tombstones
             if (tombstoneTracker != null)
-                tombstoneTracker.update(column);
+                tombstoneTracker.update(column, false);
 
             lastColumn = column;
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7f9e9a87/src/java/org/apache/cassandra/db/RangeTombstone.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RangeTombstone.java b/src/java/org/apache/cassandra/db/RangeTombstone.java
index 5e87847..90b72b7 100644
--- a/src/java/org/apache/cassandra/db/RangeTombstone.java
+++ b/src/java/org/apache/cassandra/db/RangeTombstone.java
@@ -127,6 +127,7 @@ public class RangeTombstone extends Interval<ByteBuffer, DeletionTime>
implement
                 return comparator.compare(t1.max, t2.max);
             }
         });
+        public final Set<RangeTombstone> expired = new HashSet<RangeTombstone>();
         private int atomCount;
 
         public Tracker(Comparator<ByteBuffer> comparator)
@@ -160,6 +161,9 @@ public class RangeTombstone extends Interval<ByteBuffer, DeletionTime>
implement
                 if (comparator.compare(firstColumn.name(), tombstone.max) > 0)
                     continue;
 
+                if (expired.contains(tombstone))
+                    continue;
+
                 RangeTombstone updated = new RangeTombstone(firstColumn.name(), tombstone.max,
tombstone.data);
 
                 Iterator<RangeTombstone> iter = toWrite.iterator();
@@ -194,7 +198,7 @@ public class RangeTombstone extends Interval<ByteBuffer, DeletionTime>
implement
          * If column is a IColumn, check if any tracked range is useless and
          * can be removed. If it is a RangeTombstone, add it to this tracker.
          */
-        public void update(OnDiskAtom atom)
+        public void update(OnDiskAtom atom, boolean isExpired)
         {
             if (atom instanceof RangeTombstone)
             {
@@ -215,6 +219,8 @@ public class RangeTombstone extends Interval<ByteBuffer, DeletionTime>
implement
                 }
                 ranges.addLast(t);
                 maxOrderingSet.add(t);
+                if (isExpired)
+                    expired.add(t);
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7f9e9a87/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java b/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java
index 4360b0b..433794a 100644
--- a/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java
+++ b/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java
@@ -271,8 +271,9 @@ public class LazilyCompactedRow extends AbstractCompactedRow implements
Iterable
                 RangeTombstone t = tombstone;
                 tombstone = null;
 
-                if (t.data.isGcAble(controller.gcBefore))
+                if (shouldPurge && t.data.isGcAble(controller.gcBefore))
                 {
+                    indexBuilder.tombstoneTracker().update(t, true);
                     return null;
                 }
                 else

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7f9e9a87/test/unit/org/apache/cassandra/db/RangeTombstoneTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RangeTombstoneTest.java b/test/unit/org/apache/cassandra/db/RangeTombstoneTest.java
index 59be938..15db2f6 100644
--- a/test/unit/org/apache/cassandra/db/RangeTombstoneTest.java
+++ b/test/unit/org/apache/cassandra/db/RangeTombstoneTest.java
@@ -101,6 +101,33 @@ public class RangeTombstoneTest extends SchemaLoader
             assert !isLive(cf, cf.getColumn(b(i))) : "Column " + i + " shouldn't be live";
     }
 
+
+    @Test
+    public void test7810() throws ExecutionException, InterruptedException, IOException
+    {
+        DatabaseDescriptor.setInMemoryCompactionLimit(0);
+        Table table = Table.open(KSNAME);
+        ColumnFamilyStore cfs = table.getColumnFamilyStore(CFNAME);
+        cfs.metadata.gcGraceSeconds(2);
+
+        String key = "7810";
+        RowMutation rm;
+        rm = new RowMutation(KSNAME, ByteBufferUtil.bytes(key));
+        for (int i = 10; i < 20; i++)
+            add(rm, i, 0);
+        rm.apply();
+        cfs.forceBlockingFlush();
+
+        rm = new RowMutation(KSNAME, ByteBufferUtil.bytes(key));
+        ColumnFamily cf = rm.addOrGet(CFNAME);
+        cf.delete(new DeletionInfo(b(10),b(11), cfs.getComparator(), 1, 1));
+        rm.apply();
+        cfs.forceBlockingFlush();
+        Thread.sleep(5);
+        cfs.forceMajorCompaction();
+        assertEquals(8, Util.getColumnFamily(table, Util.dk(key), CFNAME).getColumnCount());
+    }
+
     @Test
     public void test7808_1() throws ExecutionException, InterruptedException
     {


Mime
View raw message