cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefania (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-11223) Queries with LIMIT filtering on clustering columns can return less rows than expected
Date Fri, 21 Jul 2017 05:02:00 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-11223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16095785#comment-16095785
] 

Stefania commented on CASSANDRA-11223:
--------------------------------------

The problem does not affect 2.2 because NamesQueryFilter.getLiveCount() is unchanged, and
in any case GroupByPrefix will count 1 live row if toGroup is zero, which would be the case
for the GroupByPrefix used by NamesQueryFilter.columnCounter(). The queries on this type of
tables will never use SliceQueryFilter.

For 3.0+, it's a bit of a pain to revert, so I have created the follow-up [patch|https://github.com/apache/cassandra/compare/trunk...stef1927:11223-3.0].
CI is currently running. 

The patch ensures that static rows are always counted for static compact tables (which is
sufficient to fix the problem) but also assumes that a NamesQueryFilter is selecting the entire
partition if it has no clustering values. This second part is not necessary but I think it's
more correct because in this case NamesQueryFilter is not restricting anything, and existing
usages of selectsAllPartition where limited to check if the filter restricts anything, in
order to create CQL string representations of a query.

Benjamin should be back in 1 week,  but I can find a reviewer sooner if required.

> Queries with LIMIT filtering on clustering columns can return less rows than expected
> -------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-11223
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-11223
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Local Write-Read Paths
>            Reporter: Benjamin Lerer
>            Assignee: Benjamin Lerer
>             Fix For: 2.2.11, 3.0.15, 3.11.1, 4.0
>
>
> A query like {{SELECT * FROM %s WHERE b = 1 LIMIT 2 ALLOW FILTERING}} can return less
row than expected if the table has some static columns and some of the partition have no rows
matching b = 1.
> The problem can be reproduced with the following unit test:
> {code}
>     public void testFilteringOnClusteringColumnsWithLimitAndStaticColumns() throws
Throwable
>     {
>         createTable("CREATE TABLE %s (a int, b int, s int static, c int,
primary key (a, b))");
>         for (int i = 0; i < 3; i++)
>         {
>             execute("INSERT INTO %s (a, s) VALUES (?, ?)", i,
i);
>                 for (int j = 0; j < 3; j++)
>                     if (!(i == 0 && j
== 1))
>                         execute("INSERT
INTO %s (a, b, c) VALUES (?, ?, ?)", i, j, i + j);
>         }
>         assertRows(execute("SELECT * FROM %s"),
>                    row(1, 0, 1, 1),
>                    row(1, 1, 1, 2),
>                    row(1, 2, 1, 3),
>                    row(0, 0, 0, 0),
>                    row(0, 2, 0, 2),
>                    row(2, 0, 2, 2),
>                    row(2, 1, 2, 3),
>                    row(2, 2, 2, 4));
>         assertRows(execute("SELECT * FROM %s WHERE b = 1 ALLOW FILTERING"),
>                    row(1, 1, 1, 2),
>                    row(2, 1, 2, 3));
>         assertRows(execute("SELECT * FROM %s WHERE b = 1 LIMIT 2 ALLOW
FILTERING"),
>                    row(1, 1, 1, 2),
>                    row(2, 1, 2, 3)); // <--------
FAIL It returns only one row because the static row of partition 0 is counted and filtered
out in SELECT statement
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message