Hi, I was working on maintaining counters in cassandra, I read that it is not 100% accurate, I have tested them to be extremely accurate with 3.0.5 but going by docs there may be slight in accuracy.
Thinking about this I thought there may be 2 approaches to resolve this: 1. Read the existing count and write the new count if table count is the count earlier fetched using LWT transaction. 2. Read the existing writetime(count) and write the new count if writetime(count) is the writetime count earlier fetched using lightweight transaction.- For me approach1 is working, but approach 2 doesnt. Please Find below the same: superuser@cqlsh:test_keyspace> CREATE TABLE test_keyspace.test ( ... part_k int, ... clust_k text, ... count int, ... PRIMARY KEY (part_k, clust_k) ... ); superuser@cqlsh:test_keyspace> insert into test(part_k , clust_k , count ) values (2390, 'Test Ck Value', 007); superuser@cqlsh:test_keyspace> select * from test; part_k | clust_k | count --------+---------------+------- 2390 | Test Ck Value | 7 superuser@cqlsh:test_keyspace> update test set count=8 where part_k=2390 and clust_k='Test Ck Value' if count=7; # Works perfectly superuser@cqlsh:test_keyspace> select writetime(count),part_k,clust_k,count from test; writetime(count) | part_k | clust_k | count ------------------+--------+---------------+------- 1462974475292000 | 2390 | Test Ck Value | 8 # Now try to use the write time in LWT superuser@cqlsh:test_keyspace> update test set count=8 where part_k=2390 and clust_k='Test Ck Value' if writetime(count)=1462974475292000; SyntaxException: <ErrorMessage code=2000 [Syntax error in CQL query] message="line 1:82 no viable alternative at input '(' (... and clust_k='Test Ck Value' if writetime[(]...)"> Best Regards, Bhuvan Rawal