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

feat: Allow infinite reconnect retries with -1 setting #574

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

Conversation

kahirokunn
Copy link

What kind of change does this PR introduce?

This PR introduces a feature that enables Supavisor to allow infinite reconnect retries when @reconnect_retries is set to -1.

What is the current behavior?

Currently, the reconnect logic has a hard limit. Once the number of retries exceeds @reconnect_retries, Supavisor stops attempting to reconnect if the database is unavailable.

What is the new behavior?

With this change, if @reconnect_retries is set to -1, Supavisor will never stop retrying to connect to the database.

Additional context

This supports environments that use dynamic scaling or “scale to zero” strategies where the database may be intentionally down but needs to be brought online seamlessly when connections are attempted again.
Makes “infinite” reconnection behavior a conscious user choice, helping in scenarios where the DB is scaled down and then scaled back up based on metrics.

@kahirokunn kahirokunn requested a review from a team as a code owner January 24, 2025 02:09
Copy link
Member

@hauleth hauleth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how is that useful vs setting reconnection count to some large value. Because TBH I so not see how that can be safe. It is compile-time only option, so it will require some footwork to apply anyway, but I simply cannot imagine situation when you want to have really unlimited amount of retries.

@kahirokunn
Copy link
Author

I really want to SLEEP until I get a valid IP for the following EndpointSlice, but I thought it would be too much Kubernetes knowledge for the quirks.

https://kubernetes.io/docs/concepts/services-networking/endpoint-slices/#endpointslice-resource

However, I think it would be ideal if something like a plugin function could be implemented where we could write this kind of environment-dependent code and retry logic.

Enable supavisor to maintain connections when the database
is intentionally down. This supports external systems that
dynamically start and scale database instances based on
supavisor metrics, allowing for "scale to zero" scenarios.
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.

2 participants