From 82ba80a29f0d6e294f1274b23bddfc9955628d7a Mon Sep 17 00:00:00 2001 From: Ronan Dunklau Date: Tue, 9 Apr 2024 10:51:23 +0200 Subject: [PATCH] Decide to failover based on uptodate info When we notice the primary node has gone, we need to get up to date information from the other standby nodes if needed. --- pglookout/pglookout.py | 2 ++ test/conftest.py | 1 + 2 files changed, 3 insertions(+) diff --git a/pglookout/pglookout.py b/pglookout/pglookout.py index 5e92e80..11ed22c 100755 --- a/pglookout/pglookout.py +++ b/pglookout/pglookout.py @@ -494,9 +494,11 @@ def consider_failover(self, own_state, master_node, standby_nodes): self.log.warning("Not considering failover, because it's not enabled by configuration") elif self.current_master: self.cluster_monitor_check_queue.put("Master is missing, ask for immediate state check") + self.failover_decision_queue.get(timeout=self.missing_master_from_config_timeout) master_known_to_be_gone = self.current_master in self.known_gone_nodes now = time.monotonic() config_timeout_exceeded = (now - self.cluster_nodes_change_time) >= self.missing_master_from_config_timeout + if master_known_to_be_gone or config_timeout_exceeded: # we've seen a master at some point in time, but now it's # not reachable or removed from configuration, perform an diff --git a/test/conftest.py b/test/conftest.py index 869ad7e..f7daf58 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -30,6 +30,7 @@ def pgl(): pgl_.cluster_monitor._connect_to_db = Mock() # pylint: disable=protected-access pgl_.create_alert_file = Mock() pgl_.execute_external_command = Mock() + pgl_.failover_decision_queue = Mock() try: yield pgl_ finally: