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

change db into a StatefulSet #89

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

Conversation

SimoneLazzaris
Copy link

Changed the DB component into a stateful set. This avoid having two instances of the DB running on the same data, which can happen with a deployment (i.e., during an update/reconfiguration).
Also, added a shutdown command to properly shut down the database, to prevent data corruption.

What kind of change does this PR introduce?

The DB deployment is changed into a StatefulSet. Since there can only be one pod mounting and using the data volume at a time, the correct semantic is to use a StatefulSet.

What is the current behavior?

Using a deployment allows kubernetes to do rolling updates, which mean that a new pod is started on the same Persistent Volume while the old one is shutting down.

That can cause data corruption - which I've personally observed - when upgrading the helm chart.

What is the new behavior?

In the statefulset semantic, at most only one pod can be scheduled to run, so you don't have this issue.
I've also add a lifecycle command so that when the pod is shut down, postgres is commanded to shut down as well, so that it can close in a controlled fashion.

Changed the DB component into a stateful set. This avoid having two instances of
the DB running *on the same data*, which can happen with a deployment (i.e., during
an update/reconfiguration).
Also, added a shutdown command to properly shut down the database, to prevent
data corruption.
@shivani446
Copy link

Any updates on this? @SimoneLazzaris

@SimoneLazzaris
Copy link
Author

Unfortunately, no news from the supabase development team. I'd like to have this patch applied

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