带有TTL的卡桑德拉墓碑

问题描述 投票:0回答:1

我和cassandra一起工作了很长时间(DSE)并试图理解一些不太清楚的东西。我们为此插图运行DSE 5.1.9。它是单节点集群(如果您有多节点集群,请确保RF = nodeCount以简化操作)。

这是一个非常简单的例子:创建以下简单表:

CREATE TABLE mytable (
    status text,
    process_on_date_time int,
    PRIMARY KEY (status, process_on_date_time)
) WITH CLUSTERING ORDER BY (process_on_date_time ASC)
AND gc_grace_seconds = 60

我有一段代码,一次插入5k条记录,总记录达到200k,TTL为300秒。状态总是“挂起”,process_on_date_time是一个递增1的计数器,从1开始(所有唯一记录 - 基本上为1 - 200k)。

我运行代码,然后一旦完成,我将memtable刷新到磁盘。只创建了一个sstable。在此之后,没有压缩,没有修复,没有其他运行会创建或更改sstable配置。

在sstable转储之后,我进入cqlsh,打开跟踪,将一致性设置为LOCAL_ONE并进行分页。然后我重复运行:

SELECT * from mytable where status = 'pending' and process_on_date_time <= 300000;

有趣的是我看到这样的东西(删除一些文字以便于阅读):

Run X) Read 31433 live rows and 85384 tombstone cells (31k rows returned to my screen) 
Run X+1) Read 0 live rows and 76376 tombstone cells (0 rows returned to my screen - all rows expired at this point) 
Run X+2) Read 0 live rows and 60429 tombstone cells 
Run X+3) Read 0 live rows and 55894 tombstone cells 
... 
Run X+X) Read 0 live rows and 0 tombstone cells

到底是怎么回事? sstable没有改变(显然因为它是不可变的),没有其他任何插入,刷新等等。为什么墓碑数减少直到它为0?是什么导致这种行为?

我希望看到每次运行:100k墓碑读取,查询中止,因为所有TTL都已在单个sstable中过期。

cassandra datastax-enterprise
1个回答
1
投票

对于其他可能对此答案感到好奇的人,我用Datastax开了一张票,这是他们提到的:

After the tombstones pass the gc_grace_seconds they will be ignored in result sets because they are 
filtered out after they have past that point. So you are correct in the assumption that the only way for the 
tombstone warning to post would be for the data to be past their ttl but still within gc_grace.


And since they are ignored/filtered out they wont have any harmful effect 
on the system since like you said they are skipped.

所以这意味着如果TTL过期,但是在GC Grace Seconds内,当被查询时它们将被视为墓碑。如果TTL过期且GC Grace Seconds也过期,则不会将它们计为墓碑(跳过)。系统仍然必须通过过期的TTL记录“除草”,但除了处理时间之外,对查询不是“有害的”。我发现这非常有趣,因为我没有看到任何记录。

认为其他人可能对这些信息感兴趣,并且如果他们的经历不同可能会增加它。

© www.soinside.com 2019 - 2024. All rights reserved.