Don't drop replication slots in pause (#2383)

If replication slots are enabled Patroni automatically creates them for any cluster member that is supposed to stream from a given node and for any permanent slot defined in the global configuration. If the member disappears from the DCS Patroni automatically removes the replication slot for it. The same behavior was in the maintenance mode (pause).

This commit disables removal of any replication slots that don't match Patroni's expectations in pause.

Close https://github.com/zalando/patroni/issues/2314
This commit is contained in:
Alexander Kukushkin
2022-08-15 15:11:27 +02:00
committed by GitHub
parent ea2b7d2368
commit 2d08e88c3e
4 changed files with 13 additions and 7 deletions
+4 -2
View File
@@ -42,8 +42,10 @@ class TestSlotsHandler(BaseTestPostgresql):
self.p.set_role('standby_leader')
self.s.sync_replication_slots(cluster, False)
self.p.set_role('replica')
with patch.object(Postgresql, 'is_leader', Mock(return_value=False)):
self.s.sync_replication_slots(cluster, False)
with patch.object(Postgresql, 'is_leader', Mock(return_value=False)),\
patch.object(SlotsHandler, 'drop_replication_slot') as mock_drop:
self.s.sync_replication_slots(cluster, False, paused=True)
mock_drop.assert_not_called()
self.p.set_role('master')
with mock.patch('patroni.postgresql.Postgresql.role', new_callable=PropertyMock(return_value='replica')):
self.s.sync_replication_slots(cluster, False)