cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Lebresne (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-6623) Null in a cell caused by expired TTL does not work with IF clause (in CQL3)
Date Mon, 27 Jan 2014 15:19:39 GMT


Sylvain Lebresne commented on CASSANDRA-6623:

Thanks Csaba.

So this is kind of due to CASSANDRA-5619 patch, with a soup├žon of the problem from CASSANDRA-5762
thrown in.

When we generate conditions on a row internally, we currently include the row marker in the
'expected' CF. The reason is that for CASSANDRA-5619, we wanted to distinguish the cases of
CAS failure because the row doesn't exist, from CAS failure because all columns on which we
have conditions are null (but the row exists). So including the row marker in 'expected',
makes us query the row marker, which in turns allows to say if the row does exists or not
on CAS failure.

But this also means that 'UPDATE IF' checks for the row existence. Which doesn't really matter,
unless you have only 'null' conditions. Namely, doing
CREATE TABLE test (k int PRIMARY KEY, v int)
UPDATE test SET v = 1 WHERE k = 0 IF v = null
the last update won't work, because the row doesn't exist prior to the update.  And I think
this is actually the first question to ask here: do we want that update not to work? I could
see arguments for either side tbh. On the one side, since 'null' means the column doesn't
exist, if the row don't exist then the column doesn't either and in that sense the update
should work. On the other side, making it not work is somewhat more expressive since it allow
to check for 'row exists but has null value' separately of 'row doesn't exists' (which you
can already check with an 'INSERT IF NOT EXISTS'). Also, this reinforce the notion that with
conditions, UPDATE work really more like a SQL UPDATE.

So anyway, the problem Csaba is having here is a bit different. Namely, it's due to the fact
that TTL ends up removing the row marker, even if the TTL was only applied to one of the columns
and is not a proper marker of row existence.  The result is that the row marker expires in
Casba example, but since the CAS expects it to be there, it fails (and this, even though the
row actually does still exist).

I think the solution here is basically the same than in CASSANDRA-5762, we should query the
full CQL row as soon as we have a condition on it to be able to reliably say if the row exists
or not. But while we're at it, it's worth deciding if we want to preserve the current 'UPDATE
IF always checks for row existence' behavior or not.

> Null in a cell caused by expired TTL does not work with IF clause (in CQL3)
> ---------------------------------------------------------------------------
>                 Key: CASSANDRA-6623
>                 URL:
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Tests
>         Environment: One cluster with two nodes on a Linux and a Windows system. cqlsh
4.1.0 | Cassandra 2.0.4 | CQL spec 3.1.1 | Thrift protocol 19.39.0. CQL3 Column Family
>            Reporter: Csaba Seres
>            Priority: Minor
>             Fix For: 2.0.4
> IF onecell=null clause does not work if the onecell has got its null value from an expired
TTL. If onecell is updated with null value (UPDATE) then IF onecell=null works fine.
> This bug is not present when you create a table with COMPACT STORAGE directive.

This message was sent by Atlassian JIRA

View raw message