maedhroz commented on code in PR #4181:
URL: https://github.com/apache/cassandra/pull/4181#discussion_r2112626926


##########
test/distributed/org/apache/cassandra/distributed/test/sai/StrictFilteringTest.java:
##########
@@ -222,6 +225,51 @@ public void testShortReadWithRegularColumns()
         assertRows(initialRows, row(0, 1, 2));
     }
 
+    @Test
+    public void testNoShortReadAtLimit()
+    {
+        CLUSTER.schemaChange(withKeyspace("CREATE TABLE %s.no_srp_at_limit (k 
int, c int, a int, PRIMARY KEY (k, c)) WITH read_repair = 'NONE'"));
+        CLUSTER.schemaChange(withKeyspace("CREATE INDEX ON 
%s.no_srp_at_limit(a) USING 'sai'"));
+        SAIUtil.waitForIndexQueryable(CLUSTER, KEYSPACE);
+
+        CLUSTER.get(1).executeInternal(withKeyspace("INSERT INTO 
%s.no_srp_at_limit(k, c, a) VALUES (0, 2, 1) USING TIMESTAMP 5"));
+        CLUSTER.get(2).executeInternal(withKeyspace("INSERT INTO 
%s.no_srp_at_limit(k, c, a) VALUES (0, 3, 1) USING TIMESTAMP 6"));
+
+        Long srpRequestsBefore = CLUSTER.get(1).callOnInstance(() -> 
Keyspace.open(KEYSPACE).getColumnFamilyStore("no_srp_at_limit").metric.shortReadProtectionRequests.getCount());
+
+        String select = withKeyspace("SELECT * FROM %s.no_srp_at_limit WHERE k 
= 0 AND a = 1 LIMIT 1");
+        Iterator<Object[]> initialRows = 
CLUSTER.coordinator(1).executeWithPaging(select, ConsistencyLevel.ALL, 2);
+        assertRows(initialRows, row(0, 2, 1));
+
+        Long srpRequestsAfter = CLUSTER.get(1).callOnInstance(() -> 
Keyspace.open(KEYSPACE).getColumnFamilyStore("no_srp_at_limit").metric.shortReadProtectionRequests.getCount());
+        assertEquals(srpRequestsBefore, srpRequestsAfter);
+    }
+
+    @Test
+    public void testNecessaryShortRead()
+    {
+        CLUSTER.schemaChange(withKeyspace("CREATE TABLE 
%s.necessary_short_read (k int, c int, a int, PRIMARY KEY (k, c)) WITH 
read_repair = 'NONE'"));
+        CLUSTER.schemaChange(withKeyspace("CREATE INDEX ON 
%s.necessary_short_read(a) USING 'sai'"));
+        SAIUtil.waitForIndexQueryable(CLUSTER, KEYSPACE);
+
+        CLUSTER.get(1).executeInternal(withKeyspace("INSERT INTO 
%s.necessary_short_read(k, c, a) VALUES (0, 2, 1) USING TIMESTAMP 5"));
+        CLUSTER.get(2).executeInternal(withKeyspace("INSERT INTO 
%s.necessary_short_read(k, c, a) VALUES (0, 2, 2) USING TIMESTAMP 6"));
+
+        CLUSTER.get(2).executeInternal(withKeyspace("INSERT INTO 
%s.necessary_short_read(k, c, a) VALUES (0, 3, 1) USING TIMESTAMP 7"));
+        CLUSTER.get(1).executeInternal(withKeyspace("INSERT INTO 
%s.necessary_short_read(k, c, a) VALUES (0, 3, 2) USING TIMESTAMP 8"));
+
+        CLUSTER.get(1).executeInternal(withKeyspace("INSERT INTO 
%s.necessary_short_read(k, c, a) VALUES (0, 4, 1) USING TIMESTAMP 9"));
+
+        Long srpRequestsBefore = CLUSTER.get(1).callOnInstance(() -> 
Keyspace.open(KEYSPACE).getColumnFamilyStore("necessary_short_read").metric.shortReadProtectionRequests.getCount());
+
+        String select = withKeyspace("SELECT * FROM %s.necessary_short_read 
WHERE k = 0 AND a = 1 LIMIT 1");
+        Iterator<Object[]> initialRows = 
CLUSTER.coordinator(1).executeWithPaging(select, ConsistencyLevel.ALL, 3);
+        assertRows(initialRows, row(0, 4, 1));
+
+        Long srpRequestsAfter = CLUSTER.get(1).callOnInstance(() -> 
Keyspace.open(KEYSPACE).getColumnFamilyStore("necessary_short_read").metric.shortReadProtectionRequests.getCount());
+        assertEquals(srpRequestsBefore + 4L, srpRequestsAfter.longValue());

Review Comment:
   Ah, so this is an artifact of how in-JVM paging works in 5.0 vs. trunk. 
Nothing to worry about...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to