ftrujillo
ftrujillo

Reputation: 1192

Counters are not updated in cassandra

I have an issue with updating new counters in a cf. If I execute the next cql statements (the specific key is new):

UPDATE markerstats SET numbermarkers = numbermarkers + 1 WHERE projectid = 4 AND type = 'SNP';

The query execute without errors. And then I execute the next query:

SELECT * FROM markerstats

I do not get the row for the new updated counter. I have tried using the datastax java driver, devcenter and also directly throught. The definition of the cf is:

CREATE TABLE markerstats (
  projectid bigint,
  type text,
  numbermarkers counter,
  numberpartitions counter,
  PRIMARY KEY ((projectid), type)
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=864000 AND
  index_interval=128 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  default_time_to_live=0 AND
  speculative_retry='99.0PERCENTILE' AND
  memtable_flush_period_in_ms=0 AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'LZ4Compressor'};

And I am using for testing purposes a cassandra (2.0.7) single node instance.

Anyone have an idea of what could be the problem?

NOTE: I have executed previously in the cf a DELETE statement

Upvotes: 2

Views: 346

Answers (2)

hanilozmen
hanilozmen

Reputation: 450

I reproduced this situation in ScyllaDB (latest version 4.4.0) which is quite similar to Cassandra and support CQL. If you deleted the row previously, a new UPDATE command with the same WHERE condition won't insert the row to the DB. It seems like a bug but it is better not removing the counters. Instead, you can update all counter values to 0 rather than deletion.

Upvotes: 1

ftrujillo
ftrujillo

Reputation: 1192

Thanks to the help of the comments in the questions I could manage to restore the counters which were deleted by: updating the gc_grace_seconds of the cf to 0 and running a major compaction on the table.

Source: http://grokbase.com/t/cassandra/user/14a9988tww/deleting-counters

Looks like the limitation on reuse counters after deleting them is going to be removed in some 3.* version (https://issues.apache.org/jira/browse/CASSANDRA-9810)

Upvotes: 2

Related Questions