Don't rely on pg_stat_wal_receiver when deciding on pg_rewind (#2863)

As was reported by @ants on Slack it could happen that `received_tli` is ahead of replayed timeline, therefore we should stop using it when deciding on pg_rewind if postgres is running and use only `IDENTIFY_SYSTEM` via replication connection.
This commit is contained in:
Alexander Kukushkin
2023-09-15 11:32:49 +02:00
committed by GitHub
parent 75dbe4ff96
commit 5a504e67c1
+1 -1
View File
@@ -158,7 +158,7 @@ class Rewind(object):
def _get_local_timeline_lsn(self) -> Tuple[Optional[bool], Optional[int], Optional[int]]: def _get_local_timeline_lsn(self) -> Tuple[Optional[bool], Optional[int], Optional[int]]:
if self._postgresql.is_running(): # if postgres is running - get timeline from replication connection if self._postgresql.is_running(): # if postgres is running - get timeline from replication connection
in_recovery = True in_recovery = True
timeline = self._postgresql.received_timeline() or self._postgresql.get_replica_timeline() timeline = self._postgresql.get_replica_timeline()
lsn = self._postgresql.replayed_location() lsn = self._postgresql.replayed_location()
else: # otherwise analyze pg_controldata output else: # otherwise analyze pg_controldata output
in_recovery, timeline, lsn = self._get_local_timeline_lsn_from_controldata() in_recovery, timeline, lsn = self._get_local_timeline_lsn_from_controldata()