Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

docs: does insert/delete invalidate iterators?

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
活跃
技术栈
rust, typescript

调研方向

从 issue 中提到的 datastore 扫描和 iterator 缓冲路径着手:crates/core/src/host/instance_env.rs 和 crates/core/src/host/v8/syscall/common.rs。检查文档所述的 iterator 行为与这些路径的关系,然后更新相关的 iterator 文档,明确说明选项 A–D 中哪一项适用。完成标准是,文档说明插入或删除是否会影响活动中的 iterator,以及在适用的情况下,行是否为快照。

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

描述

The question

The docs don't specify whether iterators are invalidated by insert and delete, leaving this code with questionable correctness:

for (const queuer of ctx.db.game_queue.public_game.filter(true)) {
    if (logic(queuer)) {
        ctx.db.game_queue.id.delete(queuer.id);
        // Should we break here and filter again or is it safe to continue?
    }
}
// Will this loop forever, or double the table size?
for (const _ of ctx.db.game_queue.iter()) {
    ctx.db.game_queue.insert(createUniqueRow());
}

Current state

AI states that iterators hold full snapshots of the data, so the above exampeles are safe.

     - crates/core/src/host/instance_env.rs:724,748,774: datastore_*_scan_bsatn_chunks calls ChunkedWriter::
       collect_iter eagerly.
     - crates/core/src/host/v8/syscall/common.rs:299,320: scan syscalls buffer chunks then env.iters.insert(chunks.
       into_iter()).
                                                                                                                    ▄
     So the iterator is a snapshot taken at filter(true) creation; deleting the current game_queue row
     mid-iteration cannot invalidate it.

Request

Specify in the docs one of the following:
A. Insert/delete iterator invalidation is undefined and may change in the future.
B. Insert/delete should be treated as if they invalidate iterators.
C. Insert/delete does not invalidate iterators, but the data of a iterator row may change during a reducer (iterators hold references).
D. Insert/delete does not invalidate iterators. Iterators contain a snapshot of rows.

主要语言
Rust
星标
25.3k
派生
1.1k
平均合并
3 天 13 小时
30 天内合并 PR
64

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

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

clockworklabs/SpacetimeDB 的其他 Issue

查看 clockworklabs/SpacetimeDB 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

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