Don't ignore deletion info in sstable on reverse queries

patch by Sylvain Lebresne; reviewed by Aleksey Yeschenko for CASSANDRA-11733


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

Branch: refs/heads/cassandra-3.8
Commit: 76e68e9b49b1fbcb601633e6e2b8d8e1f71c7402
Parents: 30f5d44
Author: Sylvain Lebresne <sylv...@datastax.com>
Authored: Thu Jun 30 15:13:24 2016 +0200
Committer: Sylvain Lebresne <sylv...@datastax.com>
Committed: Thu Jul 7 12:54:52 2016 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../columniterator/SSTableReversedIterator.java |  2 +-
 .../cql3/validation/operations/DeleteTest.java  | 26 ++++++++++++++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/76e68e9b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 8118de1..20ed6e0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.9
+ * Fix reverse queries ignoring range tombstones (CASSANDRA-11733)
  * Improve streaming synchronization and fault tolerance (CASSANDRA-11414)
  * Avoid potential race when rebuilding CFMetaData (CASSANDRA-12098)
  * Avoid missing sstables when getting the canonical sstables (CASSANDRA-11996)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76e68e9b/src/java/org/apache/cassandra/db/columniterator/SSTableReversedIterator.java
----------------------------------------------------------------------
diff --git 
a/src/java/org/apache/cassandra/db/columniterator/SSTableReversedIterator.java 
b/src/java/org/apache/cassandra/db/columniterator/SSTableReversedIterator.java
index 14cec36..3e49a3a 100644
--- 
a/src/java/org/apache/cassandra/db/columniterator/SSTableReversedIterator.java
+++ 
b/src/java/org/apache/cassandra/db/columniterator/SSTableReversedIterator.java
@@ -356,7 +356,7 @@ public class SSTableReversedIterator extends 
AbstractSSTableIterator
         {
             deletionInfo = deletionBuilder.build();
             built = new ImmutableBTreePartition(metadata, partitionKey, 
columns, Rows.EMPTY_STATIC_ROW, rowBuilder.build(),
-                                                DeletionInfo.LIVE, 
EncodingStats.NO_STATS);
+                                                deletionInfo, 
EncodingStats.NO_STATS);
             deletionBuilder = null;
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76e68e9b/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java
----------------------------------------------------------------------
diff --git 
a/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java 
b/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java
index 76351ee..814e822 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java
@@ -1057,4 +1057,30 @@ public class DeleteTest extends CQLTester
         if (forceFlush)
             flush();
     }
+
+    @Test
+    public void testDeleteAndReverseQueries() throws Throwable
+    {
+        // This test insert rows in one sstable and a range tombstone covering 
some of those rows in another, and it
+        // validates we correctly get only the non-removed rows when doing 
reverse queries.
+
+        createTable("CREATE TABLE %s (k text, i int, PRIMARY KEY (k, i))");
+
+        for (int i = 0; i < 10; i++)
+            execute("INSERT INTO %s(k, i) values (?, ?)", "a", i);
+
+        flush();
+
+        execute("DELETE FROM %s WHERE k = ? AND i >= ? AND i <= ?", "a", 2, 7);
+
+        assertRows(execute("SELECT i FROM %s WHERE k = ? ORDER BY i DESC", 
"a"),
+            row(9), row(8), row(1), row(0)
+        );
+
+        flush();
+
+        assertRows(execute("SELECT i FROM %s WHERE k = ? ORDER BY i DESC", 
"a"),
+            row(9), row(8), row(1), row(0)
+        );
+    }
 }

Reply via email to