default_time_to_live如何删除Cassandra中没有逻辑删除的行? [英] How default_time_to_live would delete rows without tombstones in Cassandra?

查看:145
本文介绍了default_time_to_live如何删除Cassandra中没有逻辑删除的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 等待180秒(default_time_to_live)

  • sstabledump mc-1-big-Data.db

    尚未创建墓碑

  • nodetool紧凑型温度 >

  • sstabledump mc-2-big-Data.db

    墓碑已创建(而不是删除由于gc_grace_seconds而导致压缩)

  • 该测试是使用apache cassandra 3.0.13执行的。



    从示例中我得出结论,至少在3.0.13版中, default_time_to_live 不需要逻辑删除是不正确的。
    但这是一个非常简单的测试,并且我要强制使用 nodetool compact 进行重大压缩,因此我可能不会重新创建default_time_to_live魔术发挥作用的场景。



    但是C *如何在没有墓碑的情况下删除?为什么这与使用TTL插入不同?

    解决方案

    我被您提到的那篇文档愚弄了在我们的博客上回答这个问题(最后的泡菜博客)。即使我写了探索这个东西,我也可能回答得太快了,甚至说我没有明确尝试。


    要探索的另一个线索是,如果
    很合适,则使用TTL作为默认值。使用
    ‘default_time_to_live’在表级设置的TTL在
    C * 3.0 +
    中根本不会生成任何逻辑删除。


    所以我上面的句子是错误的。基本上,默认值可以在查询级别由TTL覆盖,并且我不知道Cassandra如何在没有逻辑删除的情况下进行处理。


    从示例中我得出结论,认为
    default_time_to_live 不需要墓碑,至少对于
    3.0.13版本而言。


    此外,很高兴看到您没有相信我或Datastax文档,但自己尝试一下。肯定是正确的方法。


    但是,如果C *没有墓碑,该如何删除?为什么这应该是
    与每个插入使用TTL不同的方案?


    是的,正是这样,



    C * heers。






    Alain Rodriguez-@arodream-alain @ thelastpickle。 com
    法国/西班牙



    最后的酱菜-Apache Cassandra Consulting
    http://www.thelastpickle.com


    From How is data deleted?

    Cassandra allows you to set a default_time_to_live property for an entire table. Columns and rows marked with regular TTLs are processed as described above; but when a record exceeds the table-level TTL, Cassandra deletes it immediately, without tombstoning or compaction.

    This is also answered here

    If a table has default_time_to_live on it then rows that exceed this time limit are deleted immediately without tombstones being written.

    And commented in LastPickle's post About deletes and tombstones

    Another clue to explore would be to use the TTL as a default value if that's a good fit. TTLs set at the table level with 'default_time_to_live' should not generate any tombstone at all in C*3.0+. Not tested on my hand, but I read about this.

    I've made the simplest test that I could imagine using LeveledCompactionStrategy:

    CREATE KEYSPACE IF NOT EXISTS temp WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};
    
    CREATE TABLE IF NOT EXISTS temp.test_ttl (
        key text,
        value text,
        PRIMARY KEY (key)
    ) WITH  compaction = { 'class': 'LeveledCompactionStrategy'}
      AND default_time_to_live = 180;
    

    1. INSERT INTO temp.test_ttl (key,value) VALUES ('k1','v1');
    2. nodetool flush temp
    3. sstabledump mc-1-big-Data.db
    4. wait for 180 seconds (default_time_to_live)
    5. sstabledump mc-1-big-Data.db The tombstone isn't created yet
    6. nodetool compact temp
    7. sstabledump mc-2-big-Data.db The tombstone is created (and not dropped on compaction due to gc_grace_seconds)

    The test was performed using apache cassandra 3.0.13

    From the example I conclude that isn't true that default_time_to_live not require tombstones, at least for version 3.0.13. However this is a very simple test and I'm forcing a major compaction with nodetool compact so I may not be recreating the scenario where default_time_to_live magic comes into play.

    But how would C* delete without tombstones? Why this should be a different scenario to using TTL per insert?

    解决方案

    I have been fooled by the piece of documentation you mentioned when answering this question on our blog (The Last Pickle Blog). I probably answered this one too quickly, even though I wrote this a thing 'to explore', even saying I did not try it explicitly.

    Another clue to explore would be to use the TTL as a default value if that's a good fit. TTLs set at the table level with 'default_time_to_live' should not generate any tombstone at all in C*3.0+. Not tested on my hand, but I read about this.

    So my sentence above is wrong. Basically, the default can be overwritten by the TTL at the query level and I do not see how Cassandra could handle this without tombstones.

    From the example I conclude that isn't true that default_time_to_live not require tombstones, at least for version 3.0.13.

    Also, I am glad to see you did not believe me or Datastax documentation but tried it by yourself. This is definitively the right approach.

    But how would C* delete without tombstones? Why this should be a different scenario to using TTL per insert?

    Yes, exactly this,

    C*heers.


    Alain Rodriguez - @arodream - alain@thelastpickle.com France / Spain

    The Last Pickle - Apache Cassandra Consulting http://www.thelastpickle.com

    这篇关于default_time_to_live如何删除Cassandra中没有逻辑删除的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆