fix(backups): always reset the connectivity flag after a replica backup#1642
Draft
marceloneppel wants to merge 1 commit into
Draft
fix(backups): always reset the connectivity flag after a replica backup#1642marceloneppel wants to merge 1 commit into
marceloneppel wants to merge 1 commit into
Conversation
606a252 to
0d693d7
Compare
A replica backup disables external connectivity by writing the unit peer databag "connectivity" flag to "off". The flag was only reset to "on" after the backup run via a fall-through `if disabled_connectivity:`, reachable only on the success and ExecError paths. A different exception in the backup run — or an action interruption/restart — 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). Move the reset into a `finally` block so it runs regardless of which exception (or none) the backup run raises. Also recover deployments already stuck with a stale "off" by resetting it in _on_postgresql_pebble_ready 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>
0d693d7 to
65745ea
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"after the backup run via a fall-throughif disabled_connectivity:, reachable only on the success andExecErrorpaths. A different exception in the backup run — or an action interruption/restart — 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 it runs regardless of which exception (or none) the backup run raises."off"by resetting it in_on_postgresql_pebble_readyand_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