Re: [Patch] pg_rewind: options to use restore_command from recovery.conf or command line

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Alexander Korotkov <a.korotkov@postgrespro.ru>
Cc: Alexey Kondratov <a.kondratov@postgrespro.ru>, Alvaro Herrera <alvherre@2ndquadrant.com>, Liudmila Mantrova <l.mantrova@postgrespro.ru>, Thomas Munro <thomas.munro@gmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>, David Steele <david@pgmasters.net>, Andres Freund <andres@anarazel.de>, PostgreSQL-development <pgsql-hackers@postgresql.org>, Dmitry Dolgov <9erthalion6@gmail.com>, vladimirlesk@yandex-team.ru, dsarafan@yandex-team.ru
Date: 2020-01-19T10:24:16Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Move frontend-side archive APIs from src/common/ to src/fe_utils/

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

  3. Move routine definitions of xlogarchive.c to a new header file

  4. Move routine building restore_command to src/common/

  5. Integrate recovery.conf into postgresql.conf

On Sat, Jan 18, 2020 at 06:21:22PM +0300, Alexander Korotkov wrote:
> I made some minor cleanup.  In particular, I've to fix usage of terms
> "WAL" and "WALs".  This patch sometimes use term "WAL" to specify
> single WAL file and term "WALs" to specify multiple WAL files.  But
> WAL stands for Write Ahead Log.  So, "WALs" literally stands to
> multiple logs.  And we don't use term "WALs" to describe multiple WAL
> files anywhere else.  Usage of term "WAL" to describe single file is
> not clear as well.

WAL is a method to ensure data integrity, as the docs mention:
https://www.postgresql.org/docs/11/wal-intro.html

So using WAL to tell about a WAL segment file is wrong, WALs is not a
term that actually exists.  So, in my opinion, it is fine to use "WAL
file", "WAL segment" or even "WAL segment file".

I have read through the patch, while on it..

+static int
+RestoreArchivedWALFile(const char *path, const char *xlogfname,
+                      off_t expectedSize, const char *restoreCommand)
Not a fan of putting that to pg_rewind/parsexlog.c.  It has nothing to
do with WAL parsing, and it seems to me that we could have an argument
for making this available as a frontend-only API in src/common/.

Do we actually need --target-restore-command at all?  It seems to me
that we have all we need with --restore-target-wal, and that's not
really instinctive to pass down a command via another command..

+   printf(_("  -c, --restore-target-wal              use restore_command in the postgresql.conf\n"));
+   printf(_("                                        to retrieve WAL
files from archive\n"));
The command could be part of a different configuration file, included
by postgresql.conf.

+use File::Glob ':bsd_glob';
+use File::Path qw(remove_tree make_path);
+use File::Spec::Functions qw(catdir catfile);
Is this compatible with our minimum perl requirements for the TAP
tests?

+       # Add restore_command to postgresql.conf of target cluster.
+       open(my $conf_fd, ">>", $master_conf_path) or die;
+       print $conf_fd "\nrestore_command='$restore_command'";
+       close $conf_fd;
We have append_conf() for that.
--
Michael