Re: Create replication slot in pg_basebackup if requested and not yet present

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Michael Banck <michael(dot)banck(at)credativ(dot)de>
Cc: Arthur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>, Magnus Hagander <magnus(at)hagander(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Create replication slot in pg_basebackup if requested and not yet present
Date: 2017-03-21 02:03:12
Message-ID: CAB7nPqRr7BCHFrEhRiqvFzOFrqYpyRtiVV13Bi5f9-YiWAQhMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 21, 2017 at 1:32 AM, Michael Banck
<michael(dot)banck(at)credativ(dot)de> wrote:
> On Mon, Mar 20, 2017 at 02:42:32PM +0300, Arthur Zakirov wrote:
>> Also maybe it would be good if pg_basebackup had a way to drop created slot.
>> Although "drop slot" is not related with concept of automatically created
>> slots, it will good if user will have a way to drop slots.
>
> If you want to drop the slot after basebackup finishes you'd just use a
> temporary slot (i.e. the default), or am I understanding your use-case
> incorrectly?

Yup, agreed.

> I assumed the primary use-case for creating a non-temporary slot is to
> keep it around while the standby is active.

Indeed.

/*
+ * Try to create a permanent replication slot if one is specified. Do
+ * not error out if the slot already exists, other errors are already
+ * reported by CreateReplicationSlot().
+ */
+ if (!stream->temp_slot && stream->replication_slot)
+ {
+ if (!CreateReplicationSlot(conn, stream->replication_slot,
NULL, true, true))
+ return false;
+ }
This could be part of an else taken from the previous if where
temp_slot is checked.

There should be some TAP tests included. And +1 for sharing the same
behavior as pg_receivewal.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tsunakawa, Takayuki 2017-03-21 02:03:14 Re: PATCH: Make pg_stop_backup() archive wait optional
Previous Message Andrew Dunstan 2017-03-21 02:03:02 Re: [PATCH] few fts functions for jsonb