Skip to content

Commit

Permalink
Add warning logs to Patroni reinitialisation (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp authored Oct 27, 2024
1 parent fe49ea5 commit 4286b57
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,10 @@ def _on_peer_relation_changed(self, event: HookEvent): # noqa: C901
or int(self._patroni.member_replication_lag) > 1000
)
):
logger.warning("Degraded member detected: reinitialising unit")
self.unit.status = MaintenanceStatus("reinitialising replica")
self._patroni.reinitialize_postgresql()
logger.debug("Deferring on_peer_relation_changed: reinitialising replica")
self.unit.status = MaintenanceStatus("reinitialising replica")
event.defer()
return

Expand Down Expand Up @@ -1483,6 +1484,8 @@ def _handle_workload_failures(self) -> bool:
and "postgresql_restarted" in self._peers.data[self.unit]
and self._patroni.member_replication_lag == "unknown"
):
logger.warning("Workload failure detected. Reinitialising unit.")
self.unit.status = MaintenanceStatus("reinitialising replica")
self._patroni.reinitialize_postgresql()
return True

Expand Down

0 comments on commit 4286b57

Please sign in to comment.