From e8e87bf0a14b5a85e3ea0b405d2f77003e22f7ad Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Thu, 8 Oct 2020 08:56:53 +0200 Subject: [PATCH] Don't interrupt restart or promote if lost leader lock in pause (#1726) In pause it is allowed to run postgres as master without lock. --- patroni/ha.py | 2 +- tests/test_ha.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/patroni/ha.py b/patroni/ha.py index 9e5ac5b4..4a38bd74 100644 --- a/patroni/ha.py +++ b/patroni/ha.py @@ -1182,7 +1182,7 @@ class Ha(object): return 'terminated crash recovery because of startup timeout' return 'updated leader lock during ' + self._async_executor.scheduled_action - elif not self.state_handler.bootstrapping: + elif not self.state_handler.bootstrapping and not self.is_paused(): # Don't have lock, make sure we are not promoting or starting up a master in the background if self._async_executor.scheduled_action == 'promote': with self._async_response: diff --git a/tests/test_ha.py b/tests/test_ha.py index bcb300d8..b81b7bba 100644 --- a/tests/test_ha.py +++ b/tests/test_ha.py @@ -501,6 +501,9 @@ class TestHa(PostgresInit): self.assertEqual(self.ha.run_cycle(), 'lost leader lock during restart') mock_terminate.assert_called() + self.ha.is_paused = true + self.assertEqual(self.ha.run_cycle(), 'PAUSE: restart in progress') + def test_manual_failover_from_leader(self): self.ha.fetch_node_status = get_node_status() self.ha.has_lock = true