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

Alvaro Herrera <alvherre@2ndquadrant.com>

From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Alexander Korotkov <a.korotkov@postgrespro.ru>, Kuntal Ghosh <kuntalghosh.2007@gmail.com>, Alexey Kondratov <a.kondratov@postgrespro.ru>, 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-03-26T21:56:36Z
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 2020-Mar-26, Michael Paquier wrote:

> I was looking at this patch again today and I am rather fine with the
> existing semantics.  Still I don't like much to name the frontend-side
> routine FrontendRestoreArchivedFile() and use a different name than
> the backend counterpart because we have to include xlog_internal.h in
> fe_archive.c to be able to grab XLOGDIR.

Uh, is XLOGDIR the only reason to include xlog_internal.h?  Maybe it
would be easier to have a routine in xlog.c that returns the path?
There's a few functions in xlog.c that could use it, as well.

Altough ... looking at xlog.h, that one is even worse, so I'm not sure
*where* you'd put the prototype for the new function I'm proposing.

> So here is an idea: let's move the declaration of the routines part of
> xlogarchive.c to a new header, called xlogarchive.h, and then let's
> use the same routine name for the frontend and the backend in this
> second patch.  We include xlog_internal.h already in many frontend
> tools, so that would clean up things a bit.

The patch downthread looks decent cleanup, but I'm not sure how it helps
further the objective.

(A really good cleanup could be a situation where frontend files don't
need xlog_internal.h -- for example, maybe a new file xlogpage.h could
contain struct defs that relate to page and segment headers and the
like, as well as useful macros.  I don't know if this can be made to
work -- but xlog_internal.h contains stuff like xl_parameter_change etc
as well as RmgrData which surely are of no interest to readers of wal
files ... or, say, RequestXLogSwitch.)

I don't think any such cleanup should hamper the patch at hand anyway.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services