[
https://issues.apache.org/jira/browse/CASSANDRA-12149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15603000#comment-15603000
]
Benjamin Lerer commented on CASSANDRA-12149:
--------------------------------------------
While thinking about it, I realized that the {{TokenFilter::isOnToken}} method
might not return the correct result.
If we have a query like {{SELECT * FROM %s WHERE token(a, b) > token(10, 10)
AND a < 8 AND b < 8 ALLOW FILTERING}}, as {{a}} and {{b}} have a non token
restriction the {{TokenFilter::isOnToken}} method will return {{false}}. Due to
that, Cassandra will believe that the query is not a range query and as the
call to {{TokenFilter::needFiltering}} will return {{true}} in
{{StatementRestrictions:getPartitionKeyBound}} the token restriction will be
completely ignored.
The problem can be reproduced with the following test:
{code}
@Test
public void testFilteringOnAllPartitionKeysWithTokenRestriction() throws
Throwable
{
createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY
((a, b), c))");
for (int i = 0; i < 10; i++)
{
execute("INSERT INTO %s (a,b,c,d) VALUES (?, ?, ?, ?)", i, i, i, i);
execute("INSERT INTO %s (a,b,c,d) VALUES (?, ?, ?, ?)", i, i + 10,
i + 10, i + 10);
}
assertEmpty(execute("SELECT * FROM %s WHERE token(a, b) > token(10,
10)"));
assertEmpty(execute("SELECT * FROM %s WHERE token(a, b) > token(10, 10)
AND a < 8 AND b < 8 ALLOW FILTERING"));
}
{code}
Sorry for not noticing the problem sooner.
> NullPointerException on SELECT using index with token restrictions fully
> overriden by other PK restrictions
> ------------------------------------------------------------------------------------------------------------
>
> Key: CASSANDRA-12149
> URL: https://issues.apache.org/jira/browse/CASSANDRA-12149
> Project: Cassandra
> Issue Type: Bug
> Reporter: Andrey Konstantinov
> Assignee: Alex Petrov
> Attachments: CASSANDRA-12149.txt
>
>
> If I execute the sequence of queries (see the attached file), Cassandra
> aborts a connection reporting NPE on server side. SELECT query without token
> range filter works, but does not work when token range filter is specified.
> My intent was to issue multiple SELECT queries targeting the same single
> partition, filtered by a column indexed by SASI, partitioning results by
> different token ranges.
> Output from cqlsh on SELECT is the following:
> {code}
> cqlsh> SELECT namespace, entity, timestamp, feature1, feature2 FROM
> mykeyspace.myrecordtable WHERE namespace = 'ns2' AND entity = 'entity2' AND
> feature1 > 11 AND feature1 < 31 AND token(namespace, entity) <=
> 9223372036854775807;
> ServerError: <ErrorMessage code=0000 [Server error]
> message="java.lang.NullPointerException">
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)