mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Fix in_recovery check (#2773)
The primary that is still alive wasn't properly recognized. Regression was introduced in #2652
This commit is contained in:
+1
-1
@@ -56,7 +56,7 @@ class _MemberStatus(NamedTuple):
|
||||
# If one of those is not in a response we want to count the node as not healthy/reachable
|
||||
wal: Dict[str, Any] = json.get('wal') or json['xlog']
|
||||
# abuse difference in primary/replica response format
|
||||
in_recovery = not bool(wal.get('location')) or json.get('role') in ('master', 'primary')
|
||||
in_recovery = not (bool(wal.get('location')) or json.get('role') in ('master', 'primary'))
|
||||
timeline = json.get('timeline', 0)
|
||||
dcs_last_seen = json.get('dcs_last_seen', 0)
|
||||
lsn = int(in_recovery and max(wal.get('received_location', 0), wal.get('replayed_location', 0)))
|
||||
|
||||
+4
-1
@@ -885,7 +885,10 @@ class TestHa(PostgresInit):
|
||||
member = Member(0, 'test', 1, {'api_url': 'http://127.0.0.1:8011/patroni'})
|
||||
self.ha.fetch_node_status(member)
|
||||
member = Member(0, 'test', 1, {'api_url': 'http://localhost:8011/patroni'})
|
||||
self.ha.fetch_node_status(member)
|
||||
self.ha.patroni.request = Mock()
|
||||
self.ha.patroni.request.return_value.data = b'{"wal":{"location":1},"role":"primary"}'
|
||||
ret = self.ha.fetch_node_status(member)
|
||||
self.assertFalse(ret.in_recovery)
|
||||
|
||||
@patch.object(Rewind, 'pg_rewind', true)
|
||||
@patch.object(Rewind, 'check_leader_is_not_in_recovery', true)
|
||||
|
||||
Reference in New Issue
Block a user