Open
Description
Bug Description
PoolTimeOut error happens frequently when the server is idle. If I don't give a gap between requests, the timeout doesn't happen. My guess is when there is a timeout, the pool/its implementation doesn't detect it.
Note: I know it's not a DB issue because connecting directly works (and also works after the pool has timed out). Worst part is if I make a second request, it still waits till the first one times out.
Steps:
- Create a pool and make it do a query when accessed through a tokio thread (could be any web server framework. I'm using warp)
- Make the first request. It succeeds
- Keep the server idle for some time (I kept for 1 hour - happens below that too)
- Make the second request: It times out with pool timeout. While its hanging trying to timeout, any number of parallel requests will also hang.
- Make the 3rd request after the PoolTimeOut error. It will succeed again.
Minimal Reproduction
This is how I'm initializing the pool.
match PgPoolOptions::new()
.max_connections(10)
.min_connections(3)
.connect(&prefs.pg_conn_string.clone()).await
{
Ok(pool) =>
{
println!("Successfully inited the conn pool for pg");
return Option::from(pool);
}
Err(err) => {
println!("Not able to create the conn pool for pg {:?}", err);
}
}
Info
- SQLx version: 0.6.1
- SQLx features enabled: "runtime-tokio-rustls", "postgres", "decimal", "chrono" , "tls", "uuid"
- Database server and version: PostgreSQL 14.1
- Operating system: Ubuntu 22.04
rustc --version
: rustc 1.62.1 (e092d0b6b 2022-07-16)