Cassandra - 无法删除行

Ada*_*arz 2 linux cassandra scylla

我想从 Casandra 表中删除某一特定行,但我不能。我可以从表中删除除此之外的任何其他内容。我进行了以下删除查询,但没有任何反应:

cqlsh> delete from sales.tbl where orderid=999999 and orderdate='2019/01/01';
cqlsh>
cqlsh> select * from sales.tbl where orderid=999999 and orderdate='2019/01/01';

 orderid | orderdate  | country | itemtype | orderpriority | region        | saleschannel | shipdate   | totalcost | totalprofit | totalrevenue | unitcost | unitprice | unitssold
---------+------------+---------+----------+---------------+---------------+--------------+------------+-----------+-------------+--------------+----------+-----------+-----------
  999999 | 2019/01/01 |  Canada |    Stuff |             N | North America |      Offline | 2019/01/02 |       100 |           0 |          100 |        0 |         1 |         1

(1 rows)
cqlsh>
Run Code Online (Sandbox Code Playgroud)

这是该表的示意图:

    CREATE TABLE sales.tbl1 (
        orderid bigint,
        orderdate text,
        country text,
        itemtype text,
        orderpriority text,
        region text,
        saleschannel text,
        shipdate text,
        totalcost float,
        totalprofit float,
        totalrevenue float,
        unitcost float,
        unitprice float,
        unitssold int,
        PRIMARY KEY (orderid, orderdate) ) WITH CLUSTERING ORDER BY (orderdate ASC)
        AND bloom_filter_fp_chance = 0.01
        AND caching = {'keys': 'ALL', 'rows_per_partition': 'ALL'}
        AND comment = ''
        AND compaction = {'class': 'SizeTieredCompactionStrategy'}
        AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
        AND crc_check_chance = 1.0
        AND dclocal_read_repair_chance = 0.1
        AND default_time_to_live = 0
        AND gc_grace_seconds = 1
        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';
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

Nad*_*'El 5

如果该行是使用遥远的未来时间戳创建的,则可能会发生这种奇怪的情况。在 Cassandra 和 Scylla 中,客户端可以为每次写入指定时间戳,并且最新时间戳获胜 - 无论更新的实际时间顺序如何。

例如,考虑一个客户端写入时间戳为 1000 的一行,稍后另一个客户端在时间戳 900 处发送删除。该删除不会删除任何内容 - 写入被认为是在删除之后发生的,因此删除会被忽略。

这可能正是发生在您身上的情况:时钟配置错误的客户端使用该时钟并创建了一个带有遥远未来时间戳的行。当您现在尝试时,delete from sales.tbl where orderid=999999 and orderdate='2019/01/01'; 当前时间将用作此删除的时间戳,并且它比未来时间戳更旧,因此删除将被忽略。

要检查是否属于这种情况,请尝试

select writetime(region) from sales.tbl where orderid=999999 and orderdate='2019/01/01';
Run Code Online (Sandbox Code Playgroud)

这将显示项目中“区域”列(例如)的写入时间(即时间戳)。该时间是自 UNIX 纪元(1970 年 1 月 1 日午夜 GMT)以来的微秒。如果是在未来,那么我正确地猜到了你的问题。如果是这种情况,那么要真正删除该行,您将需要执行类似的操作

delete from sales.tbl using timestamp 111111111 where orderid=999999 and orderdate='2019/01/01';
Run Code Online (Sandbox Code Playgroud)

其中时间戳“111111111”是一个数字(至少)比显示的时间戳大一select