Re: Using old master as new replica after clean switchover

From: Claudio Freire <klaussfreire(at)gmail(dot)com>
To: Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, RSR999GMAILCOM <rsr999(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Using old master as new replica after clean switchover
Date: 2019-02-22 13:34:42
Message-ID: CAGTBQpb-G+mEjoe84yG_cppwv891BJ40NJpKVgBZy-k7wu-HnA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 22, 2019 at 5:47 AM Jehan-Guillaume de Rorthais
<jgdr(at)dalibo(dot)com> wrote:
>
> On Thu, 21 Feb 2019 15:38:21 -0300
> Claudio Freire <klaussfreire(at)gmail(dot)com> wrote:
>
> > On Tue, Feb 19, 2019 at 9:44 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> > >
> > > On Tue, Feb 19, 2019 at 04:27:02PM -0800, RSR999GMAILCOM wrote:
> > > > So wanted to clarify if this procedure really requires the WAL archive
> > > > location on a shared storage ?
> > >
> > > Shared storage for WAL archives is not a requirement. It is perfectly
> > > possible to use streaming replication to get correct WAL changes.
> > > Using an archive is recommended for some deployments and depending on
> > > your requirements and data retention policy, still you could have
> > > those archives on a different host and have the restore_command of the
> > > standbyt in recovery or the archive_command of the primary save the
> > > segments to it. Depending on the frequency new WAL segments are
> > > generated, this depends of course.
> >
> > If I'm not mistaken, if you don't have WAL archive set up (a shared
> > filesystem isn't necessary, but the standby has to be able to restore
> > WAL segments from the archive), a few transactions that haven't been
> > streamed at primary shutdown could be lost, since the secondary won't
> > be able to stream anything after the primary has shut down.
>
> This has been fixed in 9.3. The primary node wait for all WAL records to be
> streamed to the connected standbys before shutting down. Including its shutdown
> checkpoint. See:
>
> https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=985bd7d49726c9f178558491d31a570d47340459
>
> Because a standby could disconnect because of some failure during the shutdown
> process, you still need to make sure the standby-to-be-promoted received the
> shutdown checkpoint though.
>
> > WAL archive can always be restored even without a primary running, hence
> > why a WAL archive is needed.
>
> No. Primary does not force a WAL switch/archive during shutdown.

That's good to know, both of the above.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2019-02-22 13:54:29 Re: Problems with plan estimates in postgres_fdw
Previous Message Amit Langote 2019-02-22 12:45:38 Re: speeding up planning with partitions