Non-deterministic connection hangup with Rust libraries tokio_postgres and sqlx when connecting with Neon on cold start

I have used sqlx and tokio_postgres and both non-deterministically get hung when connecting to neon on a cold start (it hangs indefinitely). sqlx blocks the main thread during this connection which can be catastrophic and brick the whole server; tokio_postgres luckily doesn’t block the main thread but does block the local thread (this doesn’t brick the whole server but it does prevent Axum from timing out the request). When a connection timeout is added (for both sqlx and tokio_postgres), it doesn’t timeout.

I’ve read through Connection latency and timeouts - Neon Docs and it’s not a problem with latency (I would be okay with multiple seconds of latency), the connection just straight up doesn’t work and doesn’t time out (at least if it timed out I could retry the connection which would work).

1 Like

Having the exact same issue!