Open benjamingb opened 4 months ago
I solved it by following this guide. https://github.com/launchbadge/sqlx/discussions/3232
Is that the correct way to do it when working with threads?
Why does the PgPoolOptions
configuration not work like deadpool
does?
This seems like a bug. I recently started seeing this error after bumping sqlx
and otherwise cannot identify any code changes that seem possibly related.
I can reproduce this issue (sometimes) by having two threads that use the same connection at the same time. Even when one thread finishes the other one times out after the configured 30 seconds, even though the connection should be free again.
We have also encountered this issue with DB ERROR: pool timed out while waiting for an open connection
while using:
sqlx = { version = "=0.7.4", features = [ "runtime-tokio", "postgres", "chrono" ] }
Eventually we found the discussion at: https://github.com/launchbadge/sqlx/discussions/3232
And based on the comment from @maxcountryman, gave pinning to 0.7.3 a try. Our dependency now looks like:
sqlx = { version = "=0.7.3", features = [ "runtime-tokio", "postgres", "chrono" ] }
After some testing we have not been able to reproduce the issue with 0.7.3. Either the issue really is not present in 0.7.3 or 0.73 causes the problem to happen with much less frequency with our workload.
This is also happening to me in 0.7.4
(and not on 0.7.3
) when using sqlx with sqlite and accessing it from a Rocket API. My API receives 1 call per second, and after 1~2 minutes the database pool times out as well. Downgrading to =0.7.3
fixes this issue for me at the moment. Could not test 0.8.0
yet because a version of rocket_db_pools
has not been released yet that supports it (without conflicting sqlite3 link versions).
@benjamingb How did you solve it with actix web?
Bug Description
When I try to make a query within a thread I get the following message
DB ERROR: pool timed out while waiting for an open connection
, it doesn't matter if I increase the waiting time or the connection pool it always does the sameMinimal Reproduction
This thread is invoked from another thread that is in an actor
This in turn invokes the other thread
Here I create my connection
This is how I define my connection
Info
[ "runtime-tokio-rustls", "bigdecimal", "macros", "postgres","uuid", "chrono", "migrate", "json" ]
rustc --version
: rustc 1.78.0 (9b00956e5 2024-04-29)