Skip to content

feat: add multi RO transaction opening (ENG-2135)#12

Open
prestwich wants to merge 2 commits intomainfrom
prestwich/eng-2135-multi-ro-txn
Open

feat: add multi RO transaction opening (ENG-2135)#12
prestwich wants to merge 2 commits intomainfrom
prestwich/eng-2135-multi-ro-txn

Conversation

@prestwich
Copy link
Copy Markdown
Member

Summary

  • Add begin_ro_sync_multi(n) and begin_ro_unsync_multi(n) to Environment for opening N read-only transactions guaranteed to share the same MVCC snapshot
  • Add MdbxError::SnapshotDivergence for when the optimistic retry loop (16 retries) is exhausted under extreme write contention
  • Enable safe parallel iteration over large tables without risking snapshot divergence between transactions

Implementation

Optimistic open-and-verify loop: opens N transactions, checks all txn_id() values match, drops and retries if a writer committed between opens. Generic helper begin_ro_multi deduplicates logic between sync/unsync variants.

Test plan

  • Basic snapshot consistency (sync and unsync)
  • Edge cases: n=0 returns empty vec, n=1 returns single tx
  • Concurrent writer stress test: writer committing in a loop while reader opens multi-txn sets
  • All existing tests pass
  • Clippy clean (--all-features and --no-default-features)

🤖 Generated with Claude Code

prestwich and others added 2 commits April 7, 2026 16:21
Open N read-only transactions guaranteed to share the same MVCC snapshot,
enabling safe parallel iteration over large tables. Uses an optimistic
open-and-verify loop with a hardcoded 16-retry limit, returning
MdbxError::SnapshotDivergence if retries are exhausted.

ENG-2135

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant