pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
To: Luca Ferrari <fluca1978@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: primary_conninfo and restore_command ?
Date: Thu, 10 Mar 2022 19:57:23 +0530
Message-ID: <CALj2ACULZeYWszaCSLmi-bWcHrDFBda=BLaMAA79hAYmOS3uiQ@mail.gmail.com> (raw)
In-Reply-To: <CAKoxK+4b-FER9+AcOR0P7EC0KQQW9Am=TNMm5SnCE=j_nRW1yg@mail.gmail.com>
References: <CAKoxK+4b-FER9+AcOR0P7EC0KQQW9Am=TNMm5SnCE=j_nRW1yg@mail.gmail.com>

On Thu, Mar 10, 2022 at 7:22 PM Luca Ferrari <fluca1978@gmail.com> wrote:
>
> Hi all,
> a friend of mine has shown to me a "strange" configuration of its
> physical replication server (13): he has both primary_conninfo and
> primary_slot_name, with replication slots active when queried on the
> master. So far so good, but in the configuration he has also
> restore_command to restore archived WALs from a centralized location.
> Does this make sense?
> Because if the replica cannot connect to the master, it will not start
> at all (so I guess no restore_command will be executed). On the other
> hand if the replica can connect to the primary the WALs will be
> shipped by means of streaming.
> Am I missing something?

Yes, restore_command gets executed even in standby mode when
walreceiver is unable to receive wal from primary i.e. primary stopped
sending WAL, see some comments on it [1]. It looks like
restore_command in standby mode isn't mandatory, but is advisable I
guess. I hope that clarifies your question.

[1] WaitForWALToBecomeAvailable:

     *
     * If standby mode is turned off while reading WAL from stream, we move
     * to XLOG_FROM_ARCHIVE and reset lastSourceFailed, to force fetching
     * the files (which would be required at end of recovery, e.g., timeline
     * history file) from archive or pg_wal. We don't need to kill WAL receiver
     * here because it's already stopped when standby mode is turned off at
     * the end of recovery.
     *-------
     */

           case XLOG_FROM_STREAM:

                    /*
                     * Failure while streaming. Most likely, we got here
                     * because streaming replication was terminated, or
                     * promotion was triggered. But we also get here if we
                     * find an invalid record in the WAL streamed from master,
                     * in which case something is seriously wrong. There's
                     * little chance that the problem will just go away, but
                     * PANIC is not good for availability either, especially
                     * in hot standby mode. So, we treat that the same as
                     * disconnection, and retry from archive/pg_wal again. The
                     * WAL in the archive should be identical to what was
                     * streamed, so it's unlikely that it helps, but one can
                     * hope...
                     */

Regards,
Bharath Rupireddy.





view thread (3+ messages)

Message-ID: <CALj2ACULZeYWszaCSLmi-bWcHrDFBda=BLaMAA79hAYmOS3uiQ@mail.gmail.com>
Permalink:  ../CALj2ACULZeYWszaCSLmi-bWcHrDFBda=BLaMAA79hAYmOS3uiQ@mail.gmail.com/
Also on:    postgresql.org/message-id/CALj2ACULZeYWszaCSLmi-bWcHrDFBda=BLaMAA79hAYmOS3uiQ@mail.gmail.com

 · 

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-general@postgresql.org
  Cc: bharath.rupireddyforpostgres@gmail.com, fluca1978@gmail.com
  Subject: Re: primary_conninfo and restore_command ?
  In-Reply-To: <CALj2ACULZeYWszaCSLmi-bWcHrDFBda=BLaMAA79hAYmOS3uiQ@mail.gmail.com>
  References: <CAKoxK+4b-FER9+AcOR0P7EC0KQQW9Am=TNMm5SnCE=j_nRW1yg@mail.gmail.com> <CALj2ACULZeYWszaCSLmi-bWcHrDFBda=BLaMAA79hAYmOS3uiQ@mail.gmail.com>

* 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