pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add -c/--restore-target-wal to pg_rewind
Date: Wed, 01 Apr 2020 02:13:11 +0000
Message-ID: <E1jJSsR-0006lO-Ov@gemulon.postgresql.org> (raw)

Add -c/--restore-target-wal to pg_rewind

pg_rewind needs to copy from the source cluster to the target cluster a
set of relation blocks changed from the previous checkpoint where WAL
forked up to the end of WAL on the target.  Building this list of
relation blocks requires a range of WAL segments that may not be present
anymore on the target's pg_wal, causing pg_rewind to fail.  It is
possible to work around this issue by copying manually the WAL segments
needed but this may lead to some extra and actually useless work.

This commit introduces a new option allowing pg_rewind to use a
restore_command while doing the rewind by grabbing the parameter value
of restore_command from the target cluster configuration.  This allows
the rewind operation to be more reliable, so as only the WAL segments
needed by the rewind are restored from the archives.

In order to be able to do that, a new routine is added to src/common/ to
allow frontend tools to restore files from archives using an
already-built restore command.  This version is more simple than the
backend equivalent as there is no need to handle the non-recovery case.

Author: Alexey Kondratov
Reviewed-by: Andrey Borodin, Andres Freund, Alvaro Herrera, Alexander
Korotkov, Michael Paquier
Discussion: https://postgr.es/m/a3acff50-5a0d-9a2c-b3b2-ee36168955c1@postgrespro.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a7e8ece41cf7a96d8a9c4c037cdfef304d950831

Modified Files
--------------
doc/src/sgml/ref/pg_rewind.sgml   |  28 +++++++--
src/bin/pg_rewind/parsexlog.c     |  33 ++++++++--
src/bin/pg_rewind/pg_rewind.c     |  87 ++++++++++++++++++++++++--
src/bin/pg_rewind/pg_rewind.h     |   6 +-
src/bin/pg_rewind/t/001_basic.pl  |   3 +-
src/bin/pg_rewind/t/RewindTest.pm |  70 +++++++++++++++++++--
src/common/Makefile               |   1 +
src/common/exec.c                 |   3 +-
src/common/fe_archive.c           | 128 ++++++++++++++++++++++++++++++++++++++
src/include/common/fe_archive.h   |  21 +++++++
src/include/port.h                |   3 +-
src/tools/msvc/Mkvcbuild.pm       |   4 +-
12 files changed, 360 insertions(+), 27 deletions(-)



Message-ID: <E1jJSsR-0006lO-Ov@gemulon.postgresql.org>
Permalink:  ../E1jJSsR-0006lO-Ov@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jJSsR-0006lO-Ov@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: michael@paquier.xyz
  Subject: Re: pgsql: Add -c/--restore-target-wal to pg_rewind
  In-Reply-To: <E1jJSsR-0006lO-Ov@gemulon.postgresql.org>
  References: <E1jJSsR-0006lO-Ov@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