无法使用cqlsh删除或更新Cassandra 3.11.2中的记录 [英] Not able to to delete or update a record in Cassandra 3.11.2 using cqlsh

查看:74
本文介绍了无法使用cqlsh删除或更新Cassandra 3.11.2中的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Cassandra中有一个具有以下架构的列族。

I have a column family in Cassandra with the following schema.

CREATE TABLE app_documents (
    key text PRIMARY KEY,
    created_at timestamp,
    created_by text,
    details text,
    id text
) WITH 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 dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    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 = '99PERCENTILE';
CREATE INDEX app_documents_id_idx ON app_documents (id);

在此CF中,我有一个带有键 abc的记录,并且能够使用查询选择记录

In this CF I have record with a key 'abc' and i am able to select the record using the query

select * from app_documents WHERE key = 'abc';

现在我正尝试使用以下查询删除或更新它。

Now i am trying to delete or update it using the below queries.

delete from app_documents WHERE key = 'abc';
update app_documents set created_by = 'pd' where key = 'abc';

,但以上命令对记录没有影响。表中的其他记录按预期工作,但只有该记录处于这种状态。

but the above commands having no impact on the record. Other records in the table are working as expected but only this record is kind of stuck in this state.

我的Cassandra设置仅是单个节点。

My Cassandra setup is a single node only.

推荐答案

通常,当数据库中的数据将来具有时间戳,并且通过执行 select writetime(created_by)确定时,就会发生这种情况app_documents WHERE键='abc'; -该记录的时间戳记为8月9日-未来2天。通常,获得此类条目的原因是:

Usually this happens when the data in the database has timestamp in the future, and it was confirmed by the doing select writetime(created_by) from app_documents WHERE key = 'abc'; - the record had the timestamp of 9th of August - 2 days in the future. Usual reasons for getting such entries are:


  • 客户端计算机上的时钟关闭了一段时间-始终建议使用 ntp 也在客户端计算机上运行,​​不仅在Cassandra服务器上运行

  • 时间戳是由客户端显式设置的-这可能导致无法预测的行为,并且显式时间戳应该仅在需要时(例如,由业务逻辑来设置),但是即使在这种情况下,进行一些检查以防止将来再插入时间戳也很有意义

  • clocks on the client machine are off by some amount of time - it's always recommended to have ntp running on the client machines as well, not only on Cassandra servers
  • timestamp is set explicitly by client - this could lead to unpredictable behaviour, and explicit timestamps should be set only when it's required, for example, by business logic, but even in this case it makes sense to have some checks that will prevent inserting the timestamps far in the future

这篇关于无法使用cqlsh删除或更新Cassandra 3.11.2中的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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