gpt4 book ai didi

cassandra - 当我不执行 DELETE 时,为什么有时会有 10,000 多个墓碑?

转载 作者:行者123 更新时间:2023-12-04 14:48:04 29 4
gpt4 key购买 nike

在修复 Cassandra 节点时,我有时会看到很多墓碑日志。错误看起来像这样:

org.apache.cassandra.db.filter.TombstoneOverwhelmingException: Scanned over 100001 tombstone rows during query 'SELECT * FROM my_keyspace.table_foo WHERE token(<my params>) >= token(<my params>) AND token(<my params>) <= 2988334221698479200 LIMIT 2147385647' (last scanned row partition key was ((<my params>), 7c650d21-797e-4476-93d5-b1248e187f22)); query aborted

我已阅读 here插入墓碑是将记录标记为已删除的一种方式。但是,我在这个项目中没有看到任何在此表上运行删除的代码——只是读取和插入。我缺少什么 - 如何防止这些 TombStoneOverwhelmingExceptions?

这是表定义:

CREATE TABLE my_keyspace.table_foo(
foo1 text,
year int,
month int,
foo2 text,
PRIMARY KEY ((foo1, year, month), foo2)
) WITH CLUSTERING ORDER BY (foo2 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', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND default_time_to_live = 6912000
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND speculative_retry = '99PERCENTILE';

最佳答案

However, I don't see any code in this project that runs a delete on this table - just a read and an insert.

代码可能没有运行 DELETE,但是表定义告诉 Cassandra 删除任何 >= 80 天的东西。 TTL 创建墓碑。

AND default_time_to_live = 6912000

因此,时间序列模型中 TTL 背后的思想是,它们通常按时间戳降序排列。最终发生的是,大多数用例往往只关心最近的数据,并且按时间戳的降序导致墓碑最终出现在分区的“底部”,在那里它们很少(如果有的话)被查询。

要创建这种效果,您需要创建一个具有如下定义的新表:

PRIMARY KEY ((foo1, year, month), created_time, foo2)
) WITH CLUSTERING ORDER BY (created_time DESC, foo2 ASC)

关于cassandra - 当我不执行 DELETE 时,为什么有时会有 10,000 多个墓碑?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69616967/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com