sfackler / r2d2

A generic connection pool for Rust
Apache License 2.0
1.49k stars 80 forks source link

Document relationship between `min_idle`, `idle_timeout` and `max_lifetime` #127

Open xmo-odoo opened 2 years ago

xmo-odoo commented 2 years ago

Looking at the documentation of Builder doesn't currently help understand r2d2's behaviour, when trying to answer questions like "how do I make sure there's always at least one connection at any given instant".

This is related to ivanceras/r2d2-sqlite#39: currently ::memory is basically broken (at least in the sense of pooling connection, every connection from the pool is independent).

It's possible that sqlite's mode=memory could be used to fix the issue (at least in part, it has limitations still) but sqlite will automatically delete and release the database if it has no connections open, so for this to work properly there needs to be a way to configure the pool such that once the first connection has been created there is always at least one connection in the pool at any instant.

sfackler commented 2 years ago

If you set idle_timeout and max_lifetime to None, your connections should always stay open.