From ef3401c17fb1520e2c169fc740606f602528656f Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Thu, 19 May 2022 15:06:59 +0200 Subject: [PATCH] Don't reset slots annotation if postgres isn't ready (#2306) The current state of permanent logical replication slots on the primary is queried together with `pg_current_wal_lsn()` and hence they "fail" simultaneously if Postgres isn't yet ready for accepting connections and in this case we want to avoid updating the `/status` key altogether. On K8s we don't use a dedicated object for the `/status` key, but use the same object (Endpoint or ConfigMap) as for the leader. If the `last_lsn` isn't set we avoid patching the corresponding annotation, but, the `slots` annotation was reset due to the oversight. --- patroni/dcs/kubernetes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patroni/dcs/kubernetes.py b/patroni/dcs/kubernetes.py index 52d6a2c7..059bd369 100644 --- a/patroni/dcs/kubernetes.py +++ b/patroni/dcs/kubernetes.py @@ -976,7 +976,7 @@ class Kubernetes(AbstractDCS): 'transitions': leader_observed_record.get('transitions') or '0'} if last_lsn: annotations[self._OPTIME] = str(last_lsn) - annotations['slots'] = json.dumps(slots) if slots else None + annotations['slots'] = json.dumps(slots) if slots else None resource_version = kind and kind.metadata.resource_version return self._update_leader_with_retry(annotations, resource_version, self.__ips)