Skip to content

Commit

Permalink
Decide to failover based on uptodate info
Browse files Browse the repository at this point in the history
When we notice the primary node has gone, we need to get up to date
information from the other standby nodes if needed.
  • Loading branch information
rdunklau committed Apr 9, 2024
1 parent 7c5e53c commit 82ba80a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pglookout/pglookout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 82ba80a

Please sign in to comment.