Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.
This repository was archived by the owner on Jun 16, 2026. It is now read-only.

[upstream-sync] refactor(state_store): remove ReadTxn from API; standalone reads per call (upstream #2010) #176

Description

@github-actions

Upstream Change Summary

Type: architectural-change
Difficulty: Medium
Recommendation: Adopt

Continuation of the state_store refactor series beyond what issue #168 tracked (upstream #1981–#1991). PR #2010 removes ReadTxn from the public AppStore API entirely. Read methods now come in two flavors:

  • *_in_txn(wtxn, ...) — for reads inside a write transaction (sees uncommitted writes)
  • xxx(...) — standalone reads that open their own internal snapshot

Storage::read_txn, read_txn_for_inspect, Environment::read_txn, and the ReadTxn/AnyTxn types are removed from the public surface. AppStore now carries a clone of the parent Env to support standalone reads. The MDB_READERS_FULL two-phase retry moves from Storage into AppStore standalone reads. spawn_iter_stable_paths_with_node_type is migrated from std::thread::spawn to tokio::task::spawn_blocking (the LMDB cursor is !Send so it still cannot cross .await, but the expression is idiomatic).

Upstream References

Relevant Upstream Files / Areas

  • rust/cocoindex/src/state_store/AppStore, Storage, ReadTxn, AnyTxn, storage.rs
  • rust/cocoindex/src/engine/ — all call sites migrated from env.read_txn() pattern

Recoco Considerations

  • Affected files: crates/recoco-core/src/state_store/, crates/recoco-core/src/engine/
  • Pre-condition: Verify the current state of recoco's state_store after issue [upstream-sync] refactor(state_store): LMDB isolation, async I/O, and fn-memo cache series (upstream #1981–#1991) #168 is resolved before applying this — the diff depends on what was already ported
  • Call sites pattern change: let mut rtxn = env.read_txn().await?; app_store.read_x(&mut rtxn, ...)app_store.read_x(...) (standalone); in-write-txn callers use app_store.read_x_in_txn(wtxn, ...)
  • No Python code to exclude; no feature-gating required
  • The tokio::task::spawn_blocking migration for spawn_iter_stable_paths_with_node_type is a correctness improvement for async contexts

Integration Notes

This is a direct continuation of #168's state_store series. Block this issue on #168 being resolved first. The core change is an API simplification that hides transaction management from callers — conceptually straightforward but touches many call sites. The !Send cursor constraint means the spawn_blocking migration needs special care; the upstream uses RoPrefix which wraps a raw *mut MDB_cursor.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claudeCreated or actioned by Claude AIupstream-syncIssues for syncing updates with our upstream (cocoindex-io/cocoindex)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions