[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: pgsql-hackers(at)postgresql(dot)org
Subject: [Patch] pg_rewind: options to use restore_command from recovery.conf or command line
Date: 2018-10-19 17:49:34
Message-ID: a3acff50-5a0d-9a2c-b3b2-ee36168955c1@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

Currently Postgres has options for continuous WAL files archiving, which
is quite often used along with master-replica setup. OK, then the worst
is happened and it's time to get your old master back and synchronize it
with new master (ex-replica) with pg_rewind. However, required WAL files
may be already archived and pg_rewind will fail. You can copy these
files manually, but it is difficult to calculate, which ones you need.
Anyway, it complicates building failover system with automatic failure
recovery.

I expect, that it will be a good idea to allow pg_rewind to look for a
restore_command in the target data directory recovery.conf or pass it is
as a command line argument. Then pg_rewind can use it to get missing WAL
files from the archive. I had a few talks with DBAs and came to
conclusion, that this is a highly requested feature.

I prepared a proof of concept patch (please, find attached), which does
exactly what I described above. I played with it a little and it seems
to be working, tests were accordingly updated to verify this archive
retrieval functionality too.

Patch is relatively simple excepting the one part: if we want to parse
recovery.conf (with all possible includes, etc.) and get
restore_command, then we should use guc-file.l parser, which is heavily
linked to backend, e.g. in error reporting part. So I copied it and made
frontend-safe version guc-file-fe.l. Personally, I don't think it's a
good idea, but nothing else came to mind. It is also possible to leave
the only one option -- passing restore_command as command line argument.

What do you think?

--

Alexey Kondratov

Postgres Professional: https://www.postgrespro.com

Russian Postgres Company

Attachment Content-Type Size
pg_rewind-restore_command-v1.0.patch text/x-patch 37.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2018-10-19 17:52:28 Re: pgsql: Add TAP tests for pg_verify_checksums
Previous Message Andres Freund 2018-10-19 17:17:47 Re: pgsql: Add TAP tests for pg_verify_checksums