Skip to content

bindings/rust: Add opt-in Database connection pooling#6105

Open
ongyimeng wants to merge 2 commits intotursodatabase:mainfrom
ongyimeng:feat/rust-connection-pool
Open

bindings/rust: Add opt-in Database connection pooling#6105
ongyimeng wants to merge 2 commits intotursodatabase:mainfrom
ongyimeng:feat/rust-connection-pool

Conversation

@ongyimeng
Copy link

Description

Added opt-in connection pooling to Rust bindings Database:

  • New Database::connect_pooled() API
  • New builder option max_idle_connections(...) (default 16)
  • Added internal ConnectionPool and PooledConnection wrapper (RAII return-to-pool on drop)
  • Added safety checks before recycling connections in connection.rs (can_recycle_into_pool, reset_for_reuse)
  • Added/expanded unit + integration tests for pooled behavior (reuse, disabled pool, capacity, concurrency, into_inner, mutable-method forwarding)

Motivation and context

Apps currently need to build their own pooling around Database. This change provides built-in pooling while keeping existing behavior unchanged for connect() users (pooling is opt-in via connect_pooled())

Issue #5721

Description of AI Usage

  • locating relevant Rust binding files and APIs
  • drafting the pooling implementation and test cases
  • running and iterating on validation commands (cargo fmt, cargo test -p turso, cargo clippy ... --deny=warnings)

The final code, tests, and behavior were reviewed and validated by the committer.

@ongyimeng ongyimeng requested a review from penberg as a code owner March 23, 2026 08:43
Copy link

@turso-bot turso-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review @LeMikaelF

@penberg penberg changed the title feat(bindings/rust): add opt-in Database connection pooling bindings/rust: Add opt-in Database connection pooling Mar 23, 2026
@ongyimeng
Copy link
Author

@PThorpe92 not sure who else to ask, but would you mind reviewing this when you get a chance?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant