Skip to content

PoolTimeOut error happens frequently #2276

Open
@option-greek

Description

@option-greek

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:

  1. 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)
  2. Make the first request. It succeeds
  3. Keep the server idle for some time (I kept for 1 hour - happens below that too)
  4. Make the second request: It times out with pool timeout. While its hanging trying to timeout, any number of parallel requests will also hang.
  5. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions