Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
Correctness - Transient Incorrect Response
-
Critical
-
Normal
-
Fuzz Test
-
All
-
None
-
Description
As part of our ongoing work on CASSANDRA-18275, Harry started surfacing errors shortly after we added static columns to the schema of SingleNodeSAITest. After a bit of debugging, I was able to come up with the following concrete repro:
import org.junit.Test; import org.apache.cassandra.cql3.UntypedResultSet; import org.apache.cassandra.index.sai.utils.SAIRandomizedTester; public class InMemoryIntersectionsTest extends SAIRandomizedTester { @Test public void staticAndRegularIntersection() { createTable("CREATE TABLE %s (pk int, ck int, v1 int, s1 int static, PRIMARY KEY(pk, ck))"); createIndex("CREATE INDEX ON %s(v1) USING 'sai'"); createIndex("CREATE INDEX ON %s(s1) USING 'sai'"); execute("INSERT INTO %s (pk, ck, v1) VALUES (?, ?, ?)", 0, 1, 0); execute("INSERT INTO %s (pk, ck, v1) VALUES (?, ?, ?)", 0, 2, 1); execute("INSERT INTO %s (pk, ck, v1) VALUES (?, ?, ?)", 0, 3, 2); execute("INSERT INTO %s (pk, ck, v1) VALUES (?, ?, ?)", 0, 4, 3); execute("INSERT INTO %s (pk, ck, v1) VALUES (?, ?, ?)", 0, 5, 4); execute("INSERT INTO %s (pk, ck, v1) VALUES (?, ?, ?)", 0, 6, 5); execute("INSERT INTO %s (pk, s1) VALUES (?, ?)", 0, 100); // Flushing here passes test UntypedResultSet result1 = execute("SELECT * FROM %s WHERE pk = ? AND v1 > ?", 0, 2); assertRowCount(result1, 3); UntypedResultSet result2 = execute("SELECT * FROM %s WHERE pk = ? AND v1 > ? AND s1 = ?", 0, 2, 100); assertRowCount(result2, 3); // Only returns one result! } }
Flushing memtables immediately before the queries passes the test, but it seems we have an issue with how the PrimaryKey iterators produced by static and regular column indexes are intersected when the iterators come from Memtable-attached indexes. Once the root cause of this is determined, it might make some sense to enhance RandomIntersectionTest to cover this interaction as well, just in case it turns up further problems.