cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Petrov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-12829) DELETE query with an empty IN clause can delete more than expected
Date Mon, 24 Oct 2016 19:33:58 GMT

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

Alex Petrov commented on CASSANDRA-12829:
-----------------------------------------

{{DELETE}} in this case removes the whole partition, since there's just one clustering column
and clustering list is empty.

{{UPDATE}} queries would also fail in this case with an exception:

{code}
java.lang.AssertionError: Invalid clustering for the table: org.apache.cassandra.db.Clustering$2@633128cf

	at org.apache.cassandra.db.Clustering$Serializer.serialize(Clustering.java:130)
	at org.apache.cassandra.db.rows.UnfilteredSerializer.serialize(UnfilteredSerializer.java:183)
	at org.apache.cassandra.db.rows.UnfilteredSerializer.serialize(UnfilteredSerializer.java:132)
	at org.apache.cassandra.db.rows.UnfilteredSerializer.serialize(UnfilteredSerializer.java:120)
	at org.apache.cassandra.db.rows.UnfilteredRowIteratorSerializer.serialize(UnfilteredRowIteratorSerializer.java:137)
	at org.apache.cassandra.db.rows.UnfilteredRowIteratorSerializer.serialize(UnfilteredRowIteratorSerializer.java:92)
	at org.apache.cassandra.db.partitions.PartitionUpdate$PartitionUpdateSerializer.serialize(PartitionUpdate.java:790)
	at org.apache.cassandra.db.Mutation$MutationSerializer.serialize(Mutation.java:393)
	at org.apache.cassandra.db.commitlog.CommitLog.add(CommitLog.java:249)
	at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:522)
	at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:425)
{code}

I've prepared a patch (CI pending) that handles empty clustering correctly. This logic is
slightly different from {{SELECT}} though.

> DELETE query with an empty IN clause can delete more than expected
> ------------------------------------------------------------------
>
>                 Key: CASSANDRA-12829
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-12829
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL
>         Environment: Arch Linux x64, kernel 4.7.6, Cassandra 3.9 downloaded from the
website
>            Reporter: Jason T. Bradshaw
>            Assignee: Alex Petrov
>
> When deleting from a table with a certain structure and using an *in* clause with an
empty list, the *in* clause with an empty list can be ignored, resulting in deleting more
than is expected.
> *Setup:*
> {code}
> cqlsh> create table test (a text, b text, id uuid, primary key ((a, b), id));
> cqlsh> insert into test (a, b, id) values ('a', 'b', 00000000-0000-0000-0000-000000000000);
> cqlsh> insert into test (a, b, id) values ('b', 'c', 00000000-0000-0000-0000-000000000000);
> cqlsh> insert into test (a, b, id) values ('a', 'c', 00000000-0000-0000-0000-000000000000);
> cqlsh> select * from test;
>  a | b | id
> ---+---+--------------------------------------
>  a | c | 00000000-0000-0000-0000-000000000000
>  b | c | 00000000-0000-0000-0000-000000000000
>  a | b | 00000000-0000-0000-0000-000000000000
> (3 rows)
> {code}
> *Expected:*
> {code}
> cqlsh> delete from test where a = 'a' and b in ('a', 'b', 'c') and id in ();
> cqlsh> select * from test;
>  a | b | id
> ---+---+--------------------------------------
>  a | c | 00000000-0000-0000-0000-000000000000
>  b | c | 00000000-0000-0000-0000-000000000000
>  a | b | 00000000-0000-0000-0000-000000000000
> (3 rows)
> {code}
> *Actual:*
> {code}
> cqlsh> delete from test where a = 'a' and b in ('a', 'b', 'c') and id in ();
> cqlsh> select * from test;
>  a | b | id
> ---+---+--------------------------------------
>  b | c | 00000000-0000-0000-0000-000000000000
> (1 rows)
> {code}
> Instead of deleting nothing, as the final empty *in* clause would imply, it instead deletes
everything that matches the first two clauses, acting as if the following query had been issued
instead:
> {code}
> cqlsh> delete from test where a = 'a' and b in ('a', 'b', 'c');
> {code}
> This seems to be related to the presence of a tuple clustering key, as I could not reproduce
it without one.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message