Caleb Rackliffe created CASSANDRA-19278: -------------------------------------------
Summary: AND queries involving both static and regular columns can hide matches from Memtable-attached indexes Key: CASSANDRA-19278 URL: https://issues.apache.org/jira/browse/CASSANDRA-19278 Project: Cassandra Issue Type: Bug Components: Feature/SAI Reporter: Caleb Rackliffe 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: {noformat} 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! } } {noformat} 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. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org