5

I've created a table like:

CREATE TABLE IF NOT EXISTS metrics_second(
  timestamp timestamp,
  value counter,
  PRIMARY KEY ((timestamp))
) WITH default_time_to_live=1;

And inserted some data like:

UPDATE metrics_second SET value = value + 1 WHERE timestamp = '2015-01-22 17:43:55-0800';

When executing SELECT * FROM metrics_second I always see the data, even after a minute or so, although the default_time_to_live property of the table is set to one second. Why is that?

Mark
  • 67,098
  • 47
  • 117
  • 162
  • 1
    possible duplicate of [TTL for Cassandra counter column family. Is it supported?](http://stackoverflow.com/questions/19752308/ttl-for-cassandra-counter-column-family-is-it-supported) – RussS Jan 24 '15 at 00:52
  • @RussS I'm trying to set it on the entire table, not just on a column – Mark Jan 24 '15 at 00:54
  • 3
    It doesn't make a difference. Can't have a TTL on a counter – RussS Jan 24 '15 at 01:29

1 Answers1

5

As @RussS confirmed, unfortunately Cassandra doesn't support TTL on tables or rows when there are counters.

Even if default_time_to_live is being set when creating the table and no error is being returned, Cassandra won't enforce the TTL.

Mark
  • 67,098
  • 47
  • 117
  • 162
  • 3
    FYI- I have created a JIRA ticket, asking for a warning or error message when TTLs are added to counter tables: https://issues.apache.org/jira/browse/CASSANDRA-8678 – Aaron Jan 26 '15 at 20:33