pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Hannes Erven <hannes@erven.at>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: recovery_target_time and WAL fetch with streaming replication
Date: Sun, 13 May 2018 20:45:24 +0900
Message-ID: <20180513114524.GD2481@paquier.xyz> (raw)
In-Reply-To: <1ecbd33f-ed2b-fd27-78c1-ac7a43657185@erven.at>
References: <db72ec7f-695b-1977-1f30-b422b475bab8@erven.at>
	<20180513062355.GA2481@paquier.xyz>
	<1ecbd33f-ed2b-fd27-78c1-ac7a43657185@erven.at>

On Sun, May 13, 2018 at 09:42:42AM +0200, Hannes Erven wrote:
> But when new WAL is needed, the standby will fetch /all/ WAL present on the
> master.

Fetching as much WAL as possible when recovery happens is wanted by
design, so as it recovers as much as possible.  And that's documented.

> I'd say, the standby should either:
> - always connect to the primary and fetch any WAL present

This is what a hot standby does.  It keeps waiting for WAL to become
available whichever the source used (archive, local pg_xlog or stream)
and switches between one or the other.  You can look at
WaitForWALToBecomeAvailable to get an idea of the details.  

> - stop fetching/streaming WAL when it is not needed for the current
> recovery_target

The startup process is in charge of recovery (WAL replay and definition
of from where to get the WAL available), and is the one which decides if
using streaming is necessary or not.  if streaming is used, then it
starts a WAL receiver.  If a switch from streaming to another WAL source
(local pg_xlog or archives is done), then it shuts down the WAL
receiver, consisting in sending SIGTERM to the WAL receiver and stopping
it immediately with a FATAL message (stops process immediately).  The
key point is that  WAL receiver is designed to be a light-weight
transport layer for WAL data.  In short, to be simple, it receives a set
of WAL bytes and writes them.  It does not include any logic to decode
WAL records, so it cannot know when a stop point happens or not.  It
also has no idea of the configuration within recovery.conf, which is
loaded by the startup process.

> Yes, but thats far less simple than just setting restore_target_time .

It seems to me that archiving provides the control you are looking for.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (5+ messages)  latest in thread

Message-ID: <20180513114524.GD2481@paquier.xyz>
Permalink:  ../20180513114524.GD2481@paquier.xyz/
Also on:    postgresql.org/message-id/20180513114524.GD2481@paquier.xyz

 · 

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: michael@paquier.xyz, hannes@erven.at
  Subject: Re: recovery_target_time and WAL fetch with streaming replication
  In-Reply-To: <20180513114524.GD2481@paquier.xyz>
  References: <db72ec7f-695b-1977-1f30-b422b475bab8@erven.at> <20180513062355.GA2481@paquier.xyz> <1ecbd33f-ed2b-fd27-78c1-ac7a43657185@erven.at> <20180513114524.GD2481@paquier.xyz>

* 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