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

From: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Alexey Kondratov <a(dot)kondratov(at)postgrespro(dot)ru>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Liudmila Mantrova <l(dot)mantrova(at)postgrespro(dot)ru>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, David Steele <david(at)pgmasters(dot)net>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, vladimirlesk(at)yandex-team(dot)ru, dsarafan(at)yandex-team(dot)ru
Subject: Re: [Patch] pg_rewind: options to use restore_command from recovery.conf or command line
Date: 2020-01-21 21:55:30
Message-ID: CAPpHfdvhgsHLzSprk1d+fheSUkdhZzb1nutdKaqxp0u6UTG7-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, Michael!

Thank you for your review!
The revised patch is attached.

On Sun, Jan 19, 2020 at 1:24 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> 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/.

I've put it into src/common/fe_archive.c.

> 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..

I was going to argue that --restore-target-wal is useful. But I
didn't find convincing example for that. Naturally, if one uses
restore_command during pg_rewind then why the same restore_command
can't be used in new standby. So, I've removed --restore-target-wal
argument. If we will find convincing use case we can return it any
moment.

> + 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.

I've rephrased the comment.

> +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?

All extra dependencies have been removed.

> + # 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.

Sure, thank you for pointing!

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachment Content-Type Size
v13-0001-pg_rewind-options-to-use-restore_command-from-co.patch application/octet-stream 24.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2020-01-21 21:59:50 Re: Minor issues in .pgpass
Previous Message Robert Haas 2020-01-21 21:55:20 Re: Removing pg_pltemplate and creating "trustable" extensions