fix(backups): always reset the connectivity flag after a replica backup#1842
Draft
marceloneppel wants to merge 1 commit into
Draft
fix(backups): always reset the connectivity flag after a replica backup#1842marceloneppel wants to merge 1 commit into
marceloneppel wants to merge 1 commit into
Conversation
bf74780 to
bc42bc6
Compare
bc42bc6 to
3c58bbf
Compare
A replica backup disables external connectivity by writing the unit peer databag "connectivity" flag to "off". The flag was only reset to "on" when `not self.charm.is_primary` still held after the long-running backup run, so a replica→primary failover mid-backup — or any exception or interruption in the backup run — left the flag stuck "off". Because the flag lives in the unit peer databag it survives restarts and upgrades, leaving pg_hba rejecting peer/replica connections indefinitely (the cluster can no longer talk to itself). Latch the disabled-connectivity decision before the backup run and reset it in a finally block, so the reset runs regardless of role changes or exceptions. Also recover deployments already stuck with a stale "off" by resetting it in _on_start and _on_config_changed, guarded by the cluster-wide is_creating_backup signal so a genuinely in-progress backup is not un-hidden mid-run. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
3c58bbf to
7226133
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
A replica backup disables external connectivity by writing the unit peer databag
connectivityflag to"off". The flag was only reset to"on"whennot self.charm.is_primarystill held after the (long-running) backup run, so a replica→primary failover mid-backup — or any exception/interruption in the backup run — left the flag stuck"off". Because the flag lives in the unit peer databag it survives restarts and upgrades, leavingpg_hbarejecting peer/replica connections indefinitely (the cluster can no longer talk to itself).Solution
finallyblock, so the reset runs regardless of role changes or exceptions (mirrors the K8s charm'sdisabled_connectivitypattern)."off"by resetting it in_on_startand_on_config_changed, guarded by the cluster-wideis_creating_backupsignal so a genuinely in-progress backup is not un-hidden mid-run.Unit tests cover the exception-path reset and the stale-flag recovery helper.
Checklist