Search code examples
cassandradatastaxcqlcassandra-3.0cqlsh

Cassandra update query didn't change data and didn't throw an error


Hello I am facing a problem when I am trying to execute a really simple update query in cqlsh

update "Table" set "token"='111-222-333-444' where uid='123' and "key"='somekey';

It didn't throw any error, but the value of the token is still the same. However, if I try the same query for some other field it works just fine:

update "Table" set "otherfield"='value' where uid='123' and "key"='somekey';

Any ideas why Cassandra can prevent updates for some fields?


Solution

  • Most probably the entry was inserted by client with incorrect clocks, or something like. The data in Cassandra are "versioned" by write time that could be even in the future (depending on use case). And when reading, Cassandra compares the write time of all versions of the specified column (there could be multiple versions in the data files on the disk), and selects one with highest write time.

    You need to check the write time of that column value (use the writetime function) and compare with your current time:

    select writetime(token) from Table where uid='123' and "key"='somekey';
    

    the resulting value is in the microseconds. You can remove last 3 digits, and use something like this site to convert it into human-understandable time.