Skip to content

feat(spanner): Support concurrent execution of partitions from BatchReadOnlyTransaction #433

@apstndb

Description

@apstndb

Summary

BatchReadOnlyTransaction::execute takes &mut self, preventing concurrent execution of multiple partitions. This makes it impossible to leverage Spanner's partitioned query/read parallelism.

In the Go client, multiple goroutines can call Execute concurrently on the same *BatchReadOnlyTransaction (via sync.Mutex). In Rust, the &mut chain from SessionHandle through RowIterator makes this infeasible without significant refactoring.

Possible approaches

  • Interior mutability (Mutex on session): would serialize streaming, defeating the purpose
  • New execute_concurrent method with owned session: more API surface, but cleaner abstraction
  • Make Client::get_session and RowIterator::new public (2 visibility changes): consumers acquire a separate session per partition. Works because each Partition embeds the transaction_selector -- the Spanner server uses the same snapshot regardless of which session executes it. Minimal, non-breaking

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions