Cassandra query failed to exec - 想知道原因

Cassandra query failed to exec - Want to know the reason

我正在创建一个需要 Cassandra table 结构的调度程序服务,如下所示。

CREATE TABLE IF NOT EXISTS spc_cmd_scheduler (
id timeuuid,
router_id text,
account_id text,    
mode text,
triggered_by text,
retry_count smallint,
PRIMARY KEY ((triggered_by,retry_count),id)
)WITH CLUSTERING ORDER BY (id ASC);

当我使用 PK 进行查询时,出现以下错误。我可以知道原因吗?

select count(*) from spc_cmd_scheduler  where triggered_by = 'ROUTER_ONBOARD' and retry_count < 3;

InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING"

我知道“ALLOW FILTERING”可以解决我的问题,但想知道 table 结构有什么问题。 设计符合我要求的 table 的最佳方法是什么。

只是为了说明我的要求,我需要 运行 一个调度程序来扫描此 table 并发出命令并在成功后删除该条目。如果命令失败,我需要重试 3 次。 所以这个 table 需要 SELECT、UPDATE 和 DELETE 操作。

在您的情况下,问题是 retry_count 列是分区键的一部分,我们只能对分区键使用相等运算符(=IN)柱子。仅对聚类列支持不等式运算(<>等),需要指定前面的所有聚类列。