Skip to content

Commit f09e602

Browse files
authored
Additional changes for receive/replay lsn/lag (patroni#3357)
* Properly report unknown receive lsn/lag * Do not write 0 receive/replay lsn to DCS
1 parent e3850a8 commit f09e602

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

patroni/ha.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,10 @@ def touch_member(self) -> bool:
463463
self.state_handler.timeline_wal_position()
464464
data['xlog_location'] = self._last_wal_lsn = wal_position
465465
if not timeline: # running as a standby
466-
data['receive_lsn'], data['replay_lsn'] = receive_lsn, replay_lsn
466+
if replay_lsn:
467+
data['replay_lsn'] = replay_lsn
468+
if receive_lsn:
469+
data['receive_lsn'] = receive_lsn
467470
replication_state = self.state_handler.replication_state()
468471
if replication_state:
469472
data['replication_state'] = replication_state

patroni/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ def cluster_as_json(cluster: 'Cluster') -> Dict[str, Any]:
979979
lsn_type, lag_type = f'{location}lsn', f'{location}lag'
980980

981981
lsn = getattr(m, lsn_type)
982-
if lsn is None:
982+
if not lsn:
983983
member[lsn_type] = member[lag_type] = 'unknown'
984984
elif cluster_lsn >= lsn:
985985
member[lag_type] = cluster_lsn - lsn

0 commit comments

Comments
 (0)