Skip to content

No way to set max_lifetime and idle_timeout to None for database connections #2347

@kosayoda

Description

@kosayoda

Description

When ConnectOptions is converted to sqlx::pool::PoolOptions, the max_lifetime and idle_timeout fields are set only if the value provided is not None:

if let Some(idle_timeout) = self.idle_timeout {
opt = opt.idle_timeout(Some(idle_timeout));
}

if let Some(max_lifetime) = self.max_lifetime {
opt = opt.max_lifetime(Some(max_lifetime));
}

However, None is a valid field for sqlx to enable infinite connection lifetime and no idle timeout. By default, the values are set to 30 mins and 10 mins respectively.

Use Case

I'm using an SQLite in-memory database and the data will be wiped if connections to it are closed. Therefore I want to keep a connection to the database indefinitely.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions