Skip to content

fix(backups): always reset the connectivity flag after a replica backup#1842

Draft
marceloneppel wants to merge 1 commit into
mainfrom
feature/validate-issue-1839
Draft

fix(backups): always reset the connectivity flag after a replica backup#1842
marceloneppel wants to merge 1 commit into
mainfrom
feature/validate-issue-1839

Conversation

@marceloneppel

Copy link
Copy Markdown
Member

Issue

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/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).

Solution

  • 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 (mirrors the K8s charm's disabled_connectivity pattern).
  • 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.

Unit tests cover the exception-path reset and the stale-flag recovery helper.

Checklist

  • I have added or updated any relevant documentation.
  • I have cleaned any remaining cloud resources from my accounts.

@marceloneppel marceloneppel force-pushed the feature/validate-issue-1839 branch from bf74780 to bc42bc6 Compare July 9, 2026 15:37
@github-actions github-actions Bot added the Libraries: Out of sync The charm libs used are out-of-sync label Jul 9, 2026
@marceloneppel marceloneppel force-pushed the feature/validate-issue-1839 branch from bc42bc6 to 3c58bbf Compare July 9, 2026 15:42
@marceloneppel marceloneppel added the bug Something isn't working as expected label Jul 9, 2026
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>
@marceloneppel marceloneppel force-pushed the feature/validate-issue-1839 branch from 3c58bbf to 7226133 Compare July 9, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected Libraries: Out of sync The charm libs used are out-of-sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant