select ttl() 的 Cassandra 不正确的 TTL 值

Cassandra incorrect TTL value for select ttl()

我有一个复制因子为 2 的 3 节点集群。

考虑中的列族有default_time_to_live = 3600 这是使用 alter table 设置的: cqlsh:summary> alter table match with default_time_to_live=3600;

将数据插入 columnfamily 并立即查询后,select ttl(column_name),我得到了不正确的结果。

cqlsh:summary> select ttl(end_time) from match limit 5;

ttl(end_time)

      3132
      5342
      5342
      1802
      1802

(5 行)

键空间定义:

CREATE KEYSPACE summary WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1': '2'}  AND durable_writes = true;

列族定义:

CREATE TABLE summary.match (
match_name text,
start_time bigint,
end_time bigint,
PRIMARY KEY (match_name, start_time)) WITH CLUSTERING ORDER BY (start_time ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = ''
AND compaction = {'min_threshold': '4', 'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32'}
AND compression = {'sstable_compression':'org.apache.cassandra.io.compress.LZ4Compressor'}
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 3600
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';

使用: 卡桑德拉 2.1.0 | CQL 规范 3.2.0

应该不会低于3600吧? 5342的TTL值是从哪里算进来的?

问:default_time_to_live值是如何生效的?

这不是问题。 集群中节点的时间戳不同步。

运行 ntpdate -bu <ntp server> 同步每个节点中的时钟。 那么TTL如期而至

阅读为什么同步时间对 cassandra 很重要。

https://blog.logentries.com/2014/03/synchronizing-clocks-in-a-cassandra-cluster-pt-1-the-problem/

https://ria101.wordpress.com/2011/02/08/cassandra-the-importance-of-system-clocks-avoiding-oom-and-how-to-escape-oom-meltdown/