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

From: Alexey Kondratov <a(dot)kondratov(at)postgrespro(dot)ru>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Alexander Korotkov <a(dot)korotkov(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-03-02 17:59:49
Message-ID: 6aab857f6ae253f40861f72fcf62ec4f@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2020-03-02 07:53, Michael Paquier wrote:

>
>> + * For fixed-size files, the caller may pass the expected size as an
>> + * additional crosscheck on successful recovery. If the file size is
>> not
>> + * known, set expectedSize = 0.
>> + */
>> +int
>> +RestoreArchivedWALFile(const char *path, const char *xlogfname,
>> + off_t expectedSize, const char *restoreCommand)
>
> Actually, expectedSize is IMO a bad idea, because any caller of this
> routine passing down zero could be trapped with an incorrect file
> size. So let's remove the behavior where it is possible to bypass
> this sanity check. We don't need it in pg_rewind either.
>

OK, sounds reasonable, but just to be clear. I will remove only a
possibility to bypass this sanity check (with 0), but leave expectedSize
argument intact. We still need it, since pg_rewind takes WalSegSz from
ControlFile and should pass it further, am I right?

>
>> + /* Remove trailing newline */
>> + if (strchr(cmd_output, '\n') != NULL)
>> + *strchr(cmd_output, '\n') = '\0';
>
> It seems to me that what you are looking here is to use
> pg_strip_crlf(). Thinking harder, we have pipe_read_line() in
> src/common/exec.c which does the exact same job..
>

pg_strip_crlf fits well, but would you mind if I also make
pipe_read_line external in this patch?

>
>> - /*
>> - * construct the command to be executed
>> - */
>
> Perhaps you meant "build" here.
>

Actually, the verb 'construct' is used historically applied to
archive/restore commands (see also xlogarchive.c and pgarch.c), but it
should be 'build' in (fe_)archive.c, since we have BuildRestoreCommand
there now.

All other remarks look clear for me, so I fix them in the next patch
version, thanks.

Regards
--
Alexey Kondratov

Postgres Professional https://www.postgrespro.com
The Russian Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Cary Huang 2020-03-02 19:06:57 [PATCH] Documentation bug related to client authentication using TLS certificate
Previous Message Andy Fan 2020-03-02 17:24:57 Re: [PATCH] Erase the distinctClause if the result is unique by definition