Skip to content

sqlx-core pools optionally immediately return ConnectionRefused errors instead of hanging and returning PoolTimedOut #3929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alkeryn
Copy link

@alkeryn alkeryn commented Jul 8, 2025

instead of hanging until the timeout and returning a PoolTimedOut error

Does your PR solve an issue?

fixes #744
this also would fix a bunch of duplicate / similar issues, didn't take the time to list them all.

Is this a breaking change?

following the last commit, no, it's a new options when creating the pool.

as mentioned by my comment in the issue :

if your db goes down you don't want users to have to wait a few seconds to get an error when they could get some 500 error immediately.

i understand that the pr may need some edits, but i wanted this issue to get some attention.

@alkeryn
Copy link
Author

alkeryn commented Jul 10, 2025

made it optional with the .return_con_refused() function that takes a bool.
this should no longer be a breaking change.

@alkeryn alkeryn force-pushed the pool_connection_refused_fix branch from 01373ef to 3e77113 Compare July 10, 2025 13:23
@alkeryn alkeryn changed the title sqlx pools immediately return ConnectionRefused errors instead of hanging and returning PoolTimedOut sqlx-core pools immediately return ConnectionRefused errors instead of hanging and returning PoolTimedOut Jul 10, 2025
@alkeryn alkeryn changed the title sqlx-core pools immediately return ConnectionRefused errors instead of hanging and returning PoolTimedOut sqlx-core pools optionally immediately return ConnectionRefused errors instead of hanging and returning PoolTimedOut Jul 10, 2025
it is now possible to set return_con_refused to true so that connection
refused errors are immediately returned instead of hanging until the
timeout and returning a PoolTimedOut error
@alkeryn alkeryn force-pushed the pool_connection_refused_fix branch from 3e77113 to 1583df2 Compare July 10, 2025 13:59
@alkeryn
Copy link
Author

alkeryn commented Jul 18, 2025

hey @abonander could this get a review ?
thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PoolOptions<Postgres>::connect does not error out on connection error
1 participant