【问题标题】:Reading error in cassandracassandra中的读取错误
【发布时间】:2016-09-04 00:15:28
【问题描述】:

我在尝试从 Cassandra 表中读取数据时遇到了一个奇怪的错误。我有一个单节点安装,使用默认设置。这是我正在做的查询:

  SELECT component_id,
         reading_1,
         reading_2,
         reading_3,
         date
  FROM component_readings
  WHERE park_id=2
        AND component_id IN (479)
        AND date >= '2016-04-09+0000'
        AND date <= '2016-05-08+0000';

component_readings 是一个简单的表,没有聚类条件:

CREATE TABLE component_readings (
    park_id int,
    component_id int,
    date timestamp,
    reading_1 decimal,
    reading_2 decimal,
    ...
    PRIMARY KEY ((park_id), component_id, date)
);

使用一些 component_id 值,它可以工作,而使用其他值,它会失败。这是我得到的错误:

cassandra.ReadFailure: code=1300 [Replica(s) failed to execute read] 
message="Operation failed - received 0 responses and 1 failures"
info={'required_responses': 1, 'received_responses': 0, 'failures': 1,
'consistency': 'LOCAL_ONE'}

而 cassandra 的 system.log 显示此错误:

ERROR [SharedPool-Worker-1] 2016-05-09 15:33:58,872 StorageProxy.java:1818 - 
Scanned over 100001 tombstones during query 'SELECT * FROM xrem.component_readings
WHERE park_id, component_id = 2, 479 AND date >= 2016-04-09 02:00+0200 AND date <=
2016-05-08 02:00+0200 LIMIT 5000' (last scanned row partion key was ((2, 479),
2016-05-04 17:30+0200)); query aborted

奇怪的是,我只有在从外部程序(通过 python cassandra-connector)进行查询时才会收到错误消息。如果我直接在 cqlsh shell 中制作,它可以完美运行。

我的安装是 cassandra 2.2,但我已经升级到 3.5,我得到了同样的错误。

【问题讨论】:

  • 如果在请求中将一致性级别设置为仲裁会发生什么?
  • 同样的问题:cassandra.ReadFailure: code=1300 [Replica(s) failed to execute read] message="Operation failed - received 0 responses and 1 failures" info={'received_responses': 0, 'failures': 1, 'required_responses': 1, 'consistency': 'QUORUM'}
  • 你只有一个副本?
  • 是的。正如我所说,这是一个单节点安装。
  • 如果这真的是墓碑问题,你看过stackoverflow.com/questions/27340812/…吗?

标签: cassandra


【解决方案1】:

您超出了tombstone_failure_threshold。它默认为 100'000。你可以

  • 增加cassandra.yaml中的值或
  • 清理你的墓碑

要执行后者alter 您的表并将 gc_grace_seconds 设置为 0:

ALTER TABLE component_readings WITH GC_GRACE_SECONDS = 0;

然后通过 nodetool 触发压缩。这将清除所有墓碑。

在您的单节点集群的特定场景中,您可以将 GC_GRACE_SECONDS 保留为零。但如果您这样做了,请记住,如果您想使用多个节点,请撤消此操作!

【讨论】:

  • 但是如果问题出在墓碑上,为什么如果我从 cqlsh 启动查询并从外部程序失败,查询会起作用?这对我来说没有意义(顺便说一句,解决方案有效,但我不明白为什么)。
  • @CésarGarcíaTapia,是的,我同意这很奇怪。目前有几张关于一些不一致的墓碑计数/行为或其他影响 3.x 分支的问题。也许你受到这样的影响?您可以提出错误票。
  • 我观察到类似的不一致:查询失败,paging off,但正确完成paging onshow version: cqlsh 5.0.1 |卡桑德拉 3.11.5 | CQL 规范 3.4.4 |原生协议 v4。
  • 如果您正在处理物化视图,您将无法将其设置为 0;但您仍可以将其设置为较低的值,例如 10 秒.........您将收到类似“InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot alter gc_grace_seconds of the物化视图的基表为 0,因为此值用于 TTL 未传递的更新。将 gc_grace_seconds 设置得太低可能会导致未传递的更新在重播之前过期。"
猜你喜欢
  • 2016-04-20
  • 2016-06-28
  • 2013-07-09
  • 1970-01-01
  • 1970-01-01
  • 2014-03-03
  • 2017-07-29
  • 2015-12-27
  • 2014-03-14
相关资源
最近更新 更多