From b58ddc559ec3c2fff57dfbcc7c46178405ff4c55 Mon Sep 17 00:00:00 2001 From: Oleksii Kliukin Date: Tue, 23 Aug 2016 17:29:21 +0200 Subject: [PATCH] Do not drop active replication slots. Master tried to delete all slots that did not correspond to the replica registered in Patroni. That produced an error for the slots that were active, potentially preventing drop and creation of other slots. Reported by Murat Kabilov. --- patroni/postgresql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patroni/postgresql.py b/patroni/postgresql.py index 7dff8b32..e04b8f45 100644 --- a/patroni/postgresql.py +++ b/patroni/postgresql.py @@ -884,7 +884,7 @@ $$""".format(name, ' '.join(options)), name, password, password) for slot in set(self._replication_slots) - set(slots): self.query("""SELECT pg_drop_replication_slot(%s) WHERE EXISTS(SELECT 1 FROM pg_replication_slots - WHERE slot_name = %s)""", slot, slot) + WHERE slot_name = %s AND NOT active)""", slot, slot) # create new slots for slot in set(slots) - set(self._replication_slots):