Re: pg_basebackup and replication slots - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: pg_basebackup and replication slots
Date
Msg-id 55934368.2010907@gmx.net
Whole thread Raw
In response to pg_basebackup and replication slots  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: pg_basebackup and replication slots
List 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@ex10-mbx-36009.ant.amazon.com#B8D538AC5587C84898B261FCB8C7D8A41FDE1017@ex10-mbx-36009.ant.amazon.com),
which might have an impact on the details of this change.



Attachment

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Bug in bttext_abbrev_convert()
Next
From: Fujii Masao
Date:
Subject: Re: Memory leak with XLogFileCopy since de768844 (WAL file with .partial)