Re: pg_basebackup and replication slots

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_basebackup and replication slots
Date: 2015-07-01 01:33:28
Message-ID: 55934368.2010907@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 5/21/15 8:42 AM, Peter Eisentraut wrote:
> I wonder why pg_basebackup doesn't have any support for replication slots.
>
> When relying on replication slots to hang on to WAL data, there is a gap
> between when pg_basebackup finishes and streaming replication is started
> where WAL data could be thrown away by the primary.
>
> Looking at the code, the -X stream method could easily specify a
> replication slot. (Might be nice if it could also create it in the same
> run.)

Here is a patch set for this.

(If you're looking at the patch and wondering why there is no code to
actually do anything with the replication slot, that's because the code
that does the WAL streaming is already aware of replication slots
because of the pg_receivexlog functionality that it also serves. So all
that needs to be done is set replication_slot.)

See also the concurrent discussion on (optionally?) initializing
restart_lsn when the replication slot is created
(http://www.postgresql.org/message-id/flat/B8D538AC5587C84898B261FCB8C7D8A41FDE1017(at)ex10-mbx-36009(dot)ant(dot)amazon(dot)com#B8D538AC5587C84898B261FCB8C7D8A41FDE1017@ex10-mbx-36009.ant.amazon.com),
which might have an impact on the details of this change.

Attachment Content-Type Size
0001-pg_basebackup-Add-tests-for-R-option.patch text/x-diff 1.9 KB
0002-pg_basebackup-Add-tests-for-X-option.patch text/x-diff 2.4 KB
0003-pg_basebackup-Add-slot-option.patch text/x-diff 7.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2015-07-01 01:58:12 Re: Memory leak with XLogFileCopy since de768844 (WAL file with .partial)
Previous Message Peter Geoghegan 2015-07-01 00:36:31 Re: Bug in bttext_abbrev_convert()