Reputation: 81
We have counter column family , something like that: create column family visits_counter_cf with key_validation_class =UTF8Type and comparator = 'CompositeType(LongType, LongType, UTF8Type)' and default_validation_class=CounterColumnType;
When we delete a row from this column family (we using Hector) in the CLI it looks deleted But then when we increment counters in the same row (the same rowkey) it continues increment the counters from the previous counter values (the values before deletion). Please help to understand this behavior,
Upvotes: 5
Views: 1048
Reputation: 5670
There are a number of serious limitations to the current Cassandra counter implementation. One of them is that an increment on a deleted column (or column in a deleted row) is considered undefined behavior. From the Cassandra counters wiki page:
Counter removal is intrinsically limited. For instance, if you issue very quickly the sequence "increment, remove, increment" it is possible for the removal to be lost (if for some reason the remove happens to be the last received messages). Hence, removal of counters is provided for definitive removal only, that is when the deleted counter is not increment afterwards. This holds for row deletion too: if you delete a row of counters, incrementing any counter in that row (that existed before the deletion) will result in an undetermined behavior.
In short, you should not try to reuse a deleted row in a counter column family.
Upvotes: 4