Updated Branches:
  refs/heads/trunk 885b5dac8 -> b4bcdfc15

Fix range tombstone bug

patch by slebresne; reviewed by jbellis for CASSANDRA-5805


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

Branch: refs/heads/trunk
Commit: b4bcdfc1541e069509cd12182656d45c246827bb
Parents: 885b5da
Author: Sylvain Lebresne <[email protected]>
Authored: Thu Jul 25 22:33:15 2013 +0200
Committer: Sylvain Lebresne <[email protected]>
Committed: Thu Jul 25 22:33:15 2013 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/cassandra/db/DeletionInfo.java   | 20 +++++++++++++++-----
 .../apache/cassandra/db/RangeTombstoneList.java |  2 +-
 3 files changed, 17 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b4bcdfc1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index aea73c3..0fee57e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -3,6 +3,7 @@
  * fix schema-related trigger issues (CASSANDRA-5774)
  * Better validation when accessing CQL3 table from thrift (CASSANDRA-5138)
  * Fix assertion error during repair (CASSANDRA-5801)
+ * Fix range tombstone bug (CASSANDRA-5805)
 
 
 2.0.0-beta2

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b4bcdfc1/src/java/org/apache/cassandra/db/DeletionInfo.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DeletionInfo.java 
b/src/java/org/apache/cassandra/db/DeletionInfo.java
index 32cc2a7..f61e547 100644
--- a/src/java/org/apache/cassandra/db/DeletionInfo.java
+++ b/src/java/org/apache/cassandra/db/DeletionInfo.java
@@ -336,13 +336,18 @@ public class DeletionInfo
      */
     public class InOrderTester
     {
-        private final RangeTombstoneList.InOrderTester tester;
+        /*
+         * Note that because because range tombstone are added to this 
DeletionInfo while we iterate,
+         * ranges may be null initially and we need to wait the first range to 
create the tester (once
+         * created the test will pick up new tombstones however). We do are 
guaranteed that a range tombstone
+         * will be added *before* we test any column that it may delete so 
this is ok.
+         */
+        private RangeTombstoneList.InOrderTester tester;
         private final boolean reversed;
 
         private InOrderTester(boolean reversed)
         {
             this.reversed = reversed;
-            this.tester = ranges == null || reversed ? null : 
ranges.inOrderTester();
         }
 
         public boolean isDeleted(Column column)
@@ -359,9 +364,14 @@ public class DeletionInfo
              * We don't optimize the reversed case for now because 
RangeTombstoneList
              * is always in forward sorted order.
              */
-            return reversed
-                 ? DeletionInfo.this.isDeleted(name, timestamp)
-                 : tester != null && tester.isDeleted(name, timestamp);
+            if (reversed)
+                 return DeletionInfo.this.isDeleted(name, timestamp);
+
+            // Maybe create the tester if we hadn't yet and we now have some 
ranges (see above).
+            if (tester == null && ranges != null)
+                tester = ranges.inOrderTester();
+
+            return tester != null && tester.isDeleted(name, timestamp);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b4bcdfc1/src/java/org/apache/cassandra/db/RangeTombstoneList.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RangeTombstoneList.java 
b/src/java/org/apache/cassandra/db/RangeTombstoneList.java
index e99ed9f..bb139fc 100644
--- a/src/java/org/apache/cassandra/db/RangeTombstoneList.java
+++ b/src/java/org/apache/cassandra/db/RangeTombstoneList.java
@@ -742,7 +742,7 @@ public class RangeTombstoneList implements 
Iterable<RangeTombstone>
                 }
                 else
                 {
-                    if (comparator.compare(name, ends[idx]) < 0)
+                    if (comparator.compare(name, ends[idx]) <= 0)
                         return markedAts[idx] >= timestamp;
                     else
                         idx++;

Reply via email to