Skip to content
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

Add database connection retries #82

Merged
merged 2 commits into from
Dec 14, 2020
Merged

Conversation

w3b6x9
Copy link
Member

@w3b6x9 w3b6x9 commented Nov 30, 2020

What kind of change does this PR introduce?

Prevents a temporary database connection error from shutting down entire server.

What is the current behavior?

When connection to database fails then the server shuts down because it tries to restart the epgsql process too quickly.

What is the new behavior?

When connection to database fails then the server will retry with exponential backoff and jitter, preventing server from shutting down.

Additional context

Tested this locally by restarting postgres.

NOTE: I think I discovered a better way as I was wrapping up this PR. Please hold off on merging.

NOTE: Ready for review!

@kiwicopple
Copy link
Member

@soedirgo could you please review this one? I think it will solve some of the 500's we're seeing in production actually

@soedirgo
Copy link
Member

Looks good to me, tried this on a Supabase Postgres AMI and it can carry on connecting even when I blocked inbound connections inbetween. Nice work @w3b6x9!

@soedirgo soedirgo merged commit 2a954b0 into supabase:master Dec 14, 2020
@github-actions
Copy link

🎉 This PR is included in version 0.8.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@w3b6x9 w3b6x9 deleted the db-retry branch December 14, 2020 15:07
w3b6x9 added a commit that referenced this pull request Feb 10, 2021
kiwicopple pushed a commit to kiwicopple/realtime that referenced this pull request Jun 9, 2021
Prevents a temporary database connection error from shutting down entire server.

When connection to database fails then the server will retry with exponential backoff and jitter, preventing server from shutting down.
kiwicopple pushed a commit to kiwicopple/realtime that referenced this pull request Jun 9, 2021
w3b6x9 pushed a commit that referenced this pull request Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants