You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Sylvain Lebresne (JIRA)" <ji...@apache.org> on 2017/08/18 10:08:00 UTC

[jira] [Commented] (CASSANDRA-13767) update a row which was inserted with 'IF NOT EXISTS' key word will fail siently

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

Sylvain Lebresne commented on CASSANDRA-13767:
----------------------------------------------

You're mixing LWT/Paxos queries ({{IF NOT EXISTS}}, which deals with timestamp in its own way, with "normal" queries, and that is known to lead to unpredictable results in term of ordering (what happens here is not that the 2nd insert fails, it's that it gets assigned a timestamp than is lower than the 1st query and is thus ignored). Long story short, don't mix LWT/Paxos queries with other queries (at least on the same partition) and you'll avoid issue.

> update a row which was inserted with 'IF NOT EXISTS' key word will fail siently
> -------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-13767
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-13767
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL
>         Environment: [cqlsh 5.0.1 | Cassandra 3.11.0 | CQL spec 3.4.4 | Native protocol v4]
> cassandra python driver = 3.5.0
> Run in dcoker with the following:
> docker run --name cassandra -v /data/cassandra:/var/lib/cassandra    -p9042:9042 -p9160:9160 -p7000:7000 -p7001:7001  cassandra
>            Reporter: mmh
>            Priority: Minor
>             Fix For: 3.11.0
>
>
> First, create keyspace and a table using the following
> {code:java}
> CREATE KEYSPACE scheduler WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;
> CREATE TABLE scheduler.job_info (
>     id timeuuid PRIMARY KEY,
>     create_time int,
>     cur_retry int,
>     cur_run_times int,
>     expire_time int,
>     max_retry int,
>     max_run_times int,
>     payload text,
>     period int,
>     retry_interval int,
>     status tinyint,
>     topic text,
>     type text,
>     update_time int
> ) with caching = {'keys':'ALL', 'rows_per_partition':'NONE'};
> {code}
> then, execute the following cql:
> {code:java}
> insert into job_info (id, create_time) values (5be224c6-8231-11e7-9619-9801a7a97471, 0) IF NOT EXISTS;
> insert into job_info (id, create_time) values (5be224c6-8231-11e7-9619-9801a7a97471, 1);
> select * from job_info;
> {code}
> You will find that create_time is still 0, it is not updated.
> but, if you remove the IF NOT EXISTS keyword in the first cql, the update will success.



--
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