Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

docs: does insert/delete invalidate iterators?

オープン 初心者向け
#6,146 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust, typescript

調査の方向性

issueで挙げられているdatastoreのスキャンとイテレータのバッファリングのパスから始めてください: crates/core/src/host/instance_env.rs および crates/core/src/host/v8/syscall/common.rs。ドキュメントに記載されたイテレータの動作がこれらのパスとどう関係するかを確認し、該当するイテレータのドキュメントを更新して、選択肢A~Dのどれに当てはまるかを明記してください。完了の条件は、挿入や削除がアクティブなイテレータに影響するか、該当する場合は行がスナップショットかどうかをドキュメントで答えることです。

索引モデルが 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
平均マージ
4日 6時間
マージ済み PR(30日)
43

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

clockworklabs/SpacetimeDB のほかの issue

clockworklabs/SpacetimeDB の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。