0

I have a very simple Cassandra table called campaignvariantaction with a counter column called val. I encountered a very strange problem today. For some keys, Cassandra increments the counter just fine. For others, it just doesn't do it. I'm very confused as to how this could be.

Sample output from Cassandra Shell (cqlsh) is below. Note how incrementing a counter works fine for one key (first 3 examples) and doesn't work for another (last example).

Cassandra version 2.2.7 on Ubuntu.

cqlsh:z> UPDATE campaignvariantaction SET val = val + 1 WHERE campaignvariantaction = 'campaign_variant#54408#sent' AND date = 20161118;
cqlsh:z> select * from campaignvariantaction where campaignvariantaction = 'campaign_variant#54408#sent';

 campaignvariantaction             | date     | val
-----------------------------------+----------+-----
 campaign_variant#54408#sent | 20161118 |   1

(1 rows)
cqlsh:z> UPDATE campaignvariantaction SET val = val + 1 WHERE campaignvariantaction = 'campaign_variant#54408#sent' AND date = 20161118;
cqlsh:z> select * from campaignvariantaction where campaignvariantaction = 'campaign_variant#54408#sent';

 campaignvariantaction             | date     | val
-----------------------------------+----------+-----
 campaign_variant#54408#sent | 20161118 |   2

(1 rows)

    cqlsh:z> UPDATE campaignvariantaction SET val = val + 1 WHERE campaignvariantaction = 'campaign_variant#979165#sent' AND date = 20161118;
    cqlsh:z> select * from campaignvariantaction where campaignvariantaction = 'campaign_variant#979165#sent';

     campaignvariantaction | date | val
    -----------------------+------+-----

    (0 rows)

Describe output:

cqlsh:z> describe table campaignvariantaction ;

CREATE TABLE z.campaignvariantaction (
    campaignvariantaction text,
    date int,
    val counter,
    PRIMARY KEY (campaignvariantaction, date)
) WITH CLUSTERING ORDER BY (date ASC)
    AND bloom_filter_fp_chance = 0.01
    AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'}
    AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99.0PERCENTILE';
Alex Weinstein
  • 9,823
  • 9
  • 42
  • 59
  • 2
    Did you execute delete operation for this table with the campaignvariantaction = 'campaign_variant#979165#sent' AND date = 20161118 ? Only then it will not increment – Ashraful Islam Nov 18 '16 at 07:47
  • http://stackoverflow.com/questions/13653681/apache-cassandra-delete-from-counter – Ashraful Islam Nov 18 '16 at 07:49
  • Turns out that the issue was fixed by just upgrading Cassandra - latest version (3.9) did not exhibit this issue. So looks like just an internals bug. – Alex Weinstein Nov 18 '16 at 17:30

0 Answers0