Skip to content

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

Draft
marceloneppel wants to merge 1 commit into
16/edgefrom
feature/validate-issue-1839-16edge
Draft

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

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.
  • 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 (via patroni_manager) so a genuinely in-progress backup is not un-hidden mid-run. The guard short-circuits on the cheap databag check first, so it adds no Patroni call on a healthy cluster.

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.

@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-16edge branch from 8d8f0f4 to 98a487f 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-16edge branch from 98a487f to ee636c4 Compare July 9, 2026 20:24
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