mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Avoid dropping physical slots too early (#3244)
Consider a situation: there is a permanent logical slot and primary and replica are temporary down. When Patroni is started on the former primary it starts Postgres in a standby mode, what leads to removal of physical replication slot for the replica because it has xmin. We should postpone removal of such physical slots: - on replica until there will be a leader in the cluster - on primary until Postgres is promoted
This commit is contained in:
@@ -355,6 +355,13 @@ class TestSlotsHandler(BaseTestPostgresql):
|
||||
patch.object(SlotsHandler, 'drop_replication_slot', Mock(return_value=(False, False))):
|
||||
self.s.sync_replication_slots(cluster, self.tags)
|
||||
|
||||
with patch.object(SlotsHandler, '_query', Mock(side_effect=[[('test_1', 'physical', 1, 12345, None, None,
|
||||
None, None, None)], Exception])), \
|
||||
patch.object(Cluster, 'is_unlocked', Mock(return_value=True)), \
|
||||
patch.object(SlotsHandler, 'drop_replication_slot') as mock_drop:
|
||||
self.s.sync_replication_slots(cluster, self.tags)
|
||||
mock_drop.assert_not_called()
|
||||
|
||||
@patch.object(Postgresql, 'is_primary', Mock(return_value=False))
|
||||
@patch.object(Postgresql, 'role', PropertyMock(return_value='replica'))
|
||||
@patch.object(TestTags, 'tags', PropertyMock(return_value={'nofailover': True}))
|
||||
|
||||
Reference in New Issue
Block a user