cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Garrett (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-8430) Updating a row that has a TTL produce unexpected results
Date Tue, 09 Dec 2014 21:55:13 GMT

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

Andrew Garrett commented on CASSANDRA-8430:
-------------------------------------------

[~philipthompson] Sure, the schema in my original question is one such schema.

{code}
create table test(
  pk text primary key,
  foo bigint,
  bar text
);
{code}

You'll have to forgive me for the confusing claim, but I wasn't able to re-establish a case
where just setting everything to null without involving TTLs deleted a row. I may have been
simply running into race conditions a few days ago when I was testing this. However, I do
have some examples of weird behavior that I just reproduced now:

{code}
insert into test (pk, foo, bar) values ('abc', 2, 'whatever') using ttl 60;
update test set foo=null where pk='abc';
{code}

Now at first the row has 'abc', 2, 'whatever', then after the update it has 'abc', 0, 'whatever'.
Then after 60 seconds the row gets deleted. Same thing if you set bar to null, doesn't matter
which. You can set both to null at the same time and it will have the same effect. However,
if you set foo to 0 instead of null, the row doesn't get deleted, despite them having the
same values.

Another strange case is when I do the following:

{code}
update test set bar='whatever' where pk='xyz';
update test set bar=null where pk='xyz';
{code}

After the first statement the row is present with 'xyz', 0, 'whatever'. After the second statement
the row gets deleted. I am also confused about the difference between "insert" and "update"
here. The following is valid and inserts a row with all nulls:

{code}
insert into test (pk, foo, bar) values ('allnulls', null, null);
{code}

But this doesn't add a row:

{code}
update test set foo=null, bar=null where k='allnulls';
{code}

Yet I know that if I use "update" to set non-null values it will add a row. It seems there's
a difference between insert and update but I thought they were the same thing behind the scenes.

I spent last Thursday and Friday digging through a lot of different cases and I've lost track
of all of the unexpected behaviors, and I may have gotten confused, but hopefully you can
shed some light on these cases.

> Updating a row that has a TTL produce unexpected results
> --------------------------------------------------------
>
>                 Key: CASSANDRA-8430
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-8430
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Alan Boudreault
>              Labels: cassandra, ttl
>             Fix For: 2.0.11, 2.1.2, 3.0
>
>         Attachments: test.sh
>
>
> Reported on stackoverflow: http://stackoverflow.com/questions/27280407/cassandra-ttl-gets-set-to-0-on-primary-key-if-no-ttl-is-specified-on-an-update?newreg=19e8c6757c62474985fef7c3037e8c08
> I can reproduce the issue with 2.0, 2.1 and trunk. I've attached a small script to reproduce
the issue with CCM, and here is it's output:
> {code}
> aboudreault@kovarro:~/dev/cstar/so27280407$ ./test.sh 
> Current cluster is now: local
> Insert data with a 5 sec TTL
> INSERT INTO ks.tbl (pk, foo, bar) values (1, 1, 'test') using TTL 5;
>  pk | bar  | foo
> ----+------+-----
>   1 | test |   1
> (1 rows)
> Update data with no TTL
> UPDATE ks.tbl set bar='change' where pk=1;
> sleep 6 sec
> BUG: Row should be deleted now, but isn't. and foo column has been deleted???
>  pk | bar    | foo
> ----+--------+------
>   1 | change | null
> (1 rows)
> Insert data with a 5 sec TTL
> INSERT INTO ks.tbl (pk, foo, bar) values (1, 1, 'test') using TTL 5;
>  pk | bar  | foo
> ----+------+-----
>   1 | test |   1
> (1 rows)
> Update data with a higher (10) TTL
> UPDATE ks.tbl USING TTL 10 set bar='change' where pk=1;
> sleep 6 sec
> BUG: foo column has been deleted?
>  pk | bar    | foo
> ----+--------+------
>   1 | change | null
> (1 rows)
> sleep 5 sec
> Data is deleted now after the second TTL set during the update. Is this a bug or the
expected behavior?
> (0 rows)
> {code}



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

Mime
View raw message