Re: Create subscription with `create_slot=false` and incorrect slot name

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>, Euler Taveira <euler(at)timbira(dot)com(dot)br>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Create subscription with `create_slot=false` and incorrect slot name
Date: 2017-05-25 02:15:54
Message-ID: CAD21AoCPV8vFSNQCtFPdVFqTMKC6WX9u28i1gu-tUX032_WC-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 24, 2017 at 9:41 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Wed, May 24, 2017 at 7:31 PM, Peter Eisentraut
> <peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:
>> On 5/23/17 02:33, Kuntal Ghosh wrote:
>>>> The command succeed even if slot_name is invalid. That's because slot_name
>>>> isn't validated. ReplicationSlotValidateName() should be called in
>>>> parse_subscription_options() to avoid a pilot error. IMHO we should prevent
>>>> a future error (use of invalid slot name).
>>>>
>>> +1. Since, slot_name can be provided even when create_slot is set
>>> false, it should be validated as well while creating the subscription.
>>
>> This came up in a previous thread. It is up to the publishing end what
>> slot names it accepts. So running the validation locally is incorrect.
>
> That argument seems pretty tenuous; surely both ends are PostgreSQL,
> and the rules for valid slot names aren't likely to change very often.
>
> But even if we accept it as true, I still don't like the idea that a
> DROP can just fail, especially with no real guidance as to how to fix
> things so it doesn't fail. Ideas:
>
> 1. If we didn't create the slot (and have never connected to it?),
> don't try to drop it.
>
> 2. Emit some kind of a HINT telling people about ALTER SUBSCRIPTION ..
> SET (slot_name = NONE).
>
> 3. ???
>

+1 to #2 idea. We already emit such errhint when connection to the
publisher failed. I think we can do the same thing in this case.

subscriptioncmds.c:L928

wrconn = walrcv_connect(conninfo, true, subname, &err);
if (wrconn == NULL)
ereport(ERROR,
(errmsg("could not connect to publisher when attempting to "
"drop the replication slot \"%s\"", slotname),
errdetail("The error was: %s", err),
errhint("Use ALTER SUBSCRIPTION ... SET (slot_name = NONE) "
"to disassociate the subscription from the
slot.")));

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2017-05-25 02:23:44 Re: retry shm attach for windows (WAS: Re: OK, so culicidae is *still* broken)
Previous Message Masahiko Sawada 2017-05-25 01:47:49 Re: Get stuck when dropping a subscription during synchronizing table