From 5a504e67c132b979a4c687fd87f0f589884167f5 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Fri, 15 Sep 2023 11:32:49 +0200 Subject: [PATCH] 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. --- patroni/postgresql/rewind.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patroni/postgresql/rewind.py b/patroni/postgresql/rewind.py index 73bccb44..6e1aab88 100644 --- a/patroni/postgresql/rewind.py +++ b/patroni/postgresql/rewind.py @@ -158,7 +158,7 @@ class Rewind(object): 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 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() else: # otherwise analyze pg_controldata output in_recovery, timeline, lsn = self._get_local_timeline_lsn_from_controldata()