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 15:23:55 +0900
Message-ID: <20180513062355.GA2481@paquier.xyz> (raw)
In-Reply-To: <db72ec7f-695b-1977-1f30-b422b475bab8@erven.at>
References: <db72ec7f-695b-1977-1f30-b422b475bab8@erven.at>
On Sun, May 13, 2018 at 01:39:48AM +0200, Hannes Erven wrote:
> what is Postgresql's strategy when to fetch WAL from the master while in
> streaming replication, and could it be tweaked?
>
> I'm using a physical streaming replication slave to have a database lagging
> behind about one month behind the primary, by setting "recovery_target_time"
> to the desired point in time.
> This setting is periodically advanced by a cronjob to allow the replica to
> roll forward. It's a 10.3-1 install on Debian.
I think that you are coplicating your life here.
Fetching WAL from a primary (or another standby) cannot be directly per
se. By definition, any WAL present will e automatically fetched and
synced on the standby. Now, it is not usually the moment WAL is fetched
and synced on a standby that matters, it is the moment it is replayed.
For example, what people usually want to be protected from is an
infortunate DROP TABLE on the primary run by an administrator to be
immediately replayed on the standby, losing the data. Hence delaying
when WAL is replayed can offer some protection, and this can be achieved
by setting recovery_min_apply_delay in recovery.conf. This will cause
WAL records replaying transactions commits to wait for the amount of
time specified by this parameter, giving you the time to recover from
any failures with a standby which has a controlled synced delta.
> One option of course would be to use some transfer mechanism external to
> Postgresql... but so far I'm thinking there must be any easier way?
Another option I can think of here is to use a specific restore_command
instead of streaming replication. Simply archive a WAL segment on the
primary with some meta-data like the time it was archived, and then
allow the standby to recover the segment only after a delta has passed.
The can allow a more evenly distribution of segments.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
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: <20180513062355.GA2481@paquier.xyz>
References: <db72ec7f-695b-1977-1f30-b422b475bab8@erven.at> <20180513062355.GA2481@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