【问题标题】:Select distinct gives incorrect values even if performed on primary key Cassandra即使在主键 Cassandra 上执行 Select distinct 也会给出不正确的值
【发布时间】:2016-08-01 07:01:26
【问题描述】:

我正在运行 Cassandra 版本 2.1.2 和 cqlsh 5.0.1

这里是 weather.log 表,weather 是具有一致性级别 1 的键空间。 我配置了 2 个节点。

CREATE KEYSPACE weather WITH replication = {'class': 'NetworkTopologyStrategy', 'us-east': '1'} AND durable_writes = true;

CREATE TABLE weather.log ( ip inet, ts timestamp, city text, country text, PRIMARY KEY (ip, ts) ) WITH CLUSTERING ORDER BY (ts DESC) AND bloom_filter_fp_chance = 0.01 AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}' AND comment = '' AND compaction = {'min_threshold': '4', 'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32'} AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'} 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 = '99.0PERCENTILE';

当我们运行查询时。

select distinct ip from weather.log

我们得到不一致的错误响应。一旦我们得到 99,下次我们得到 1600 等等。[实际数字应该是 > 2000]

我也尝试过将一致性级别设置为 ALL 的此查询。没用。

为什么会这样?我需要得到所有的钥匙。如何获取所有主键?

【问题讨论】:

  • 您是否尝试添加 ALLOW FILTERING 子句?
  • SELECT DISTINCT 只能用于主键。
  • @Raedwald ip 是主键吧?
  • @Whitefret 没有。我没有使用 ALLOW FILTERING 因为 ip 是主键。
  • 你是只做这个请求还是在查询之前写?

标签: cassandra distinct cql datastax consistency


【解决方案1】:

看起来你可能会受到CASSANDRA-8940 的影响。我建议更新到最新的 2.1.x 版本并验证此问题是否已为您解决。

【讨论】:

    猜你喜欢
    • 2017-06-29
    • 1970-01-01
    • 1970-01-01
    • 2020-12-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多