Cassandra: Query answers 500 on a partition whose items were all deleted

未关闭 适合新手
#795 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
databases

调研方向

从 crates/storage-cassandra/src/data/query.rs 开始,其中结果循环调用 cassandra_util::get_column(&row, "item_data", "query parse")?,并在 delete_item.rs 留下的仅含静态数据的行上失败。在那里跳过 item_data 为 null 的行,并检查 Scan 读取是否有相同的循环。当对完全被删除的分区执行 Query 时,无论是否带 ConsistentRead,都返回 Count: 0,并通过 tests/ 中的双目标测试证明,即为完成。

由索引模型根据 Issue 内容生成。

描述

On the Cassandra backend, a Query whose partition key names a partition that held items, all of which have since been deleted, answers 500 InternalServerError instead of an empty result. Amazon DynamoDB answers 200 with Count: 0.

Reproduction

A table with a hash key pk (S) and a range key sk (S), on a local Cassandra 4.1 node:

  1. PutItem {"pk": "a", "sk": "1"}.
  2. Query with pk = :p, :p = "a": Count: 1.
  3. DeleteItem {"pk": "a", "sk": "1"}.
  4. The same Query, with ConsistentRead false and true: both answer 500 {'Code': 'InternalServerError', 'Message': 'Internal server error'}.

A conditional delete (attribute_exists(pk)) in step 3 gives the same result. The server logs:

ERROR extenddb_storage_cassandra::cassandra_util: query parse parse column 'item_data': General error: Column or Udt property 'item_data' is empty

Where

crates/storage-cassandra/src/data/delete_item.rs writes partition_max_delete_timestamp before it deletes the row (update_partition_max_delete_timestamp_at). On a table with a sort key that column is STATIC (ddl.rs), so once the last item is gone the partition still holds a row with only the static column set. The Query path in crates/storage-cassandra/src/data/query.rs reads item_data from every row it gets back with cassandra_util::get_column(&row, "item_data", "query parse")?, which fails on that static-only row.

Seen on main (5ff323beb) and on the branch of #424; the reproduction above was run against the #424 branch.

Suggested fix

Skip rows whose item_data is null in the Query (and Scan, if it has the same read) result loop, as rows with no item, rather than failing the request.

Test

A dual-target test in tests/ that puts one item, deletes it and asserts that a Query of its partition answers Count: 0, with and without ConsistentRead.

主要语言
Rust
星标
517
派生
60
平均合并
5 天 4 小时
30 天内合并 PR
76

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ExtendDB/extenddb 的其他 Issue

查看 ExtendDB/extenddb 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。