cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J Robert Ray <>
Subject Mixing CAS and TTL.
Date Tue, 25 Feb 2014 07:09:39 GMT
Hi, I am trying to mix CAS and TTL and am wondering if this behavior that I
am seeing is expected.

I'm on 2.0.2 and using the java datastax 2.0.0-rc3 client.

In my application, a server "claims" a row by assigning a value to a row
using CAS, expecting the column to start out null. The column has a
shortish TTL and while the application "owns" the row, it will periodically
refresh the TTL on the column. If the application dies, the column expires
and can be claimed by another server. My problem is that after the TTL
expires, no server can successfully claim a row using a CAS update.

If I set a TTL on a column with a null value (for demonstration purposes;
the real code sets to a non-null value):

UPDATE foo USING TTL 120 SET col = null WHERE ...;

This CAS update will succeed:

UPDATE foo USING TTL 120 SET col = 'some value' IF col = null; // [applied]
= true
UPDATE foo USING TTL 120 SET col = 'some value' IF col = 'foo'; //
[applied] = true, col = null

However, if I allow the TTL to expire, then the same update now fails.

UPDATE foo USING TTL 120 SET col = 'some value' IF col = null; // [applied]
= false

Note, after it fails, the ResultSet column definitions only contains
"[applied]" and so does not provide the value of the 'col' column which
failed the conditional update.

It seems a null value is a different flavor of null than an expired column.
Is it possible to make an update conditional on if a column is expired? Is
this behavior expected or a bug?


View raw message