Fix bug with priority failover (#3297)

We should ignor the former leader with higher priority when it reports the same LSN as the current node.

This bug could be a contributing factor to issues described in #3295


In addition to that mock socket.getaddrinfo() call in test_api.py to avoid hitting DNS servers.
This commit is contained in:
Alexander Kukushkin
2025-02-28 09:48:16 +01:00
committed by GitHub
parent 92c4f9fbb5
commit a316105412
3 changed files with 21 additions and 2 deletions
+3
View File
@@ -1076,6 +1076,9 @@ class TestHa(PostgresInit):
# if there is a higher-priority node but it has a lower WAL position then this node should race
self.ha.fetch_node_status = get_node_status(failover_priority=6, wal_position=9)
self.assertTrue(self.ha._is_healthiest_node(self.ha.old_cluster.members))
# if the old leader is a higher-priority node on the same WAL position then this node should race
self.ha.fetch_node_status = get_node_status(failover_priority=6)
self.assertTrue(self.ha._is_healthiest_node(self.ha.old_cluster.members, leader=self.ha.old_cluster.leader))
self.ha.fetch_node_status = get_node_status(wal_position=11) # accessible, in_recovery, wal position ahead
self.assertFalse(self.ha._is_healthiest_node(self.ha.old_cluster.members))
# in synchronous_mode consider itself healthy if the former leader is accessible in read-only and ahead of us