-
Notifications
You must be signed in to change notification settings - Fork 1k
Allow drop slots when it gets deleted from the manifest #2089
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
Conversation
3dcd007
to
8c0c0ca
Compare
@@ -625,7 +625,7 @@ func (c *Cluster) checkAndSetGlobalPostgreSQLConfiguration(pod *v1.Pod, effectiv | |||
} | |||
|
|||
// check if there exist only config updates that require a restart of the primary | |||
if !util.SliceContains(restartPrimary, false) && len(configToSet) == 0 { | |||
if len(restartPrimary) > 0 && !util.SliceContains(restartPrimary, false) && len(configToSet) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there's nothing to set requiresMasterRestart
would become true
here which is wrong
e2e/tests/test_e2e.py
Outdated
SELECT slot_name | ||
FROM pg_replication_slots | ||
WHERE slot_name = '%s'; | ||
""" % (slot_to_remove) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the slot query not be defined once so we do formatting inside the assertions (self.eventuallyEqual)
👍 |
1 similar comment
👍 |
Problem
Users can specify replication slots in the Postgres manifest and they are added to the database via Patroni REST API. When the slot is removed from the manifest, it won't get deleted in the database. Here we follow the convention of the operator never dropping database objects because manifest edits could have been wrong accidentally.
However, with logical replication slots the situation is a little different. If they are not used, diskspace will grow until it's exhausted. Our users are mostly not aware of this and think the slot will be gone when it's not desired anymore in the manifest. Some users check the database and still find the slot. So they call
pg_drop_replication_slot
function to drop it only to be surprised seconds later that the slot is recreated.Solution
The operator should drop replication slots when they are removed from the manifest by updating the Patroni config. So far, our code only adds new slots or slots that differ from existing slots to the configToSet. Patroni's config endpoint only merges the patches - it does not override the slots section.
To drop the replication slots that get deleted from the manifest, we can set the unused slots to null in the current Patroni's configuration and using
PATCH /config
.