pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix corner case failure of new standby to follow new primary.
Date: Wed, 09 Jun 2021 20:43:56 +0000
Message-ID: <E1lr53M-0006Ln-79@gemulon.postgresql.org> (raw)

Fix corner case failure of new standby to follow new primary.

This only happens if (1) the new standby has no WAL available locally,
(2) the new standby is starting from the old timeline, (3) the promotion
happened in the WAL segment from which the new standby is starting,
(4) the timeline history file for the new timeline is available from
the archive but the WAL files for are not (i.e. this is a race),
(5) the WAL files for the new timeline are available via streaming,
and (6) recovery_target_timeline='latest'.

Commit ee994272ca50f70b53074f0febaec97e28f83c4e introduced this
logic and was an improvement over the previous code, but it mishandled
this case. If recovery_target_timeline='latest' and restore_command is
set, validateRecoveryParameters() can change recoveryTargetTLI to be
different from receiveTLI. If streaming is then tried afterward,
expectedTLEs gets initialized with the history of the wrong timeline.
It's supposed to be a list of entries explaining how to get to the
target timeline, but in this case it ends up with a list of entries
explaining how to get to the new standby's original timeline, which
isn't right.

Dilip Kumar and Robert Haas, reviewed by Kyotaro Horiguchi.

Discussion: http://postgr.es/m/CAFiTN-sE-jr=LB8jQuxeqikd-Ux+jHiXyh4YDiZMPedgQKup0g@mail.gmail.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0826564292156762d32c183c6708c94564fcad1c

Modified Files
--------------
src/backend/access/transam/xlog.c                | 10 ++-
src/test/recovery/t/025_stuck_on_old_timeline.pl | 96 ++++++++++++++++++++++++
src/test/recovery/t/cp_history_files             | 10 +++
3 files changed, 115 insertions(+), 1 deletion(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1lr53M-0006Ln-79@gemulon.postgresql.org>
Permalink:  ../E1lr53M-0006Ln-79@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lr53M-0006Ln-79@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: rhaas@postgresql.org
  Subject: Re: pgsql: Fix corner case failure of new standby to follow new primary.
  In-Reply-To: <E1lr53M-0006Ln-79@gemulon.postgresql.org>
  References: <E1lr53M-0006Ln-79@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox