Re: [HACKERS] logical replication syntax (was DROP SUBSCRIPTION,query cancellations and slot handling) - Mailing list pgsql-hackers

From Petr Jelinek
Subject Re: [HACKERS] logical replication syntax (was DROP SUBSCRIPTION,query cancellations and slot handling)
Date
Msg-id ad83b4a4-613e-bb58-f153-613efe6d5429@2ndquadrant.com
Whole thread Raw
In response to Re: [HACKERS] logical replication syntax (was DROP SUBSCRIPTION,query cancellations and slot handling)  (Masahiko Sawada <sawada.mshk@gmail.com>)
List pgsql-hackers
On 09/05/17 11:44, Masahiko Sawada wrote:
> On Tue, May 9, 2017 at 5:57 PM, Petr Jelinek
> <petr.jelinek@2ndquadrant.com> wrote:
>> On 09/05/17 10:51, Masahiko Sawada wrote:
>>> On Tue, May 9, 2017 at 5:39 PM, Petr Jelinek
>>> <petr.jelinek@2ndquadrant.com> wrote:
>>>> On 09/05/17 07:07, Peter Eisentraut wrote:
>>>>> On 5/8/17 23:23, Peter Eisentraut wrote:
>>>>>> The way this uses RESTRICT and CASCADE appears to be backwards from its
>>>>>> usual meaning.  Normally, CASCADE when dropping an object that is still
>>>>>> used by others will cause those other objects to be dropped.  The
>>>>>> equivalent here would be DROP REPLICATION SLOT + CASCADE would drop the
>>>>>> subscription.
>>>>>>
>>>>>> What we want to simulate instead is an "auto" dependency of the slot on
>>>>>> the subscription.  So you can drop the slot separately (subject to other
>>>>>> restrictions), and it is dropped automatically when the subscription is
>>>>>> dropped.  To avoid that, you can disassociate the slot from the
>>>>>> subscription, which you have implemented.
>>>>>>
>>>>>> I think we can therefore do without RESTRICT/CASCADE here.  If a slot is
>>>>>> associated with the subscription, it should be there when we drop the
>>>>>> subscription.  Otherwise, the user has to disassociate the slot and take
>>>>>> care of it manually.  So just keep the "cascade" behavior.
>>>>>>
>>>>>> Similarly, I wouldn't check first whether the slot exists.  If the
>>>>>> subscription is associated with the slot, it should be there.
>>>
>>> IIUC in this design, for example if we mistakenly create a
>>> subscription without creating replication slot and corresponding
>>> replication slot doesn't exist on publisher, we cannot drop
>>> subscription until we create corresponding replication slot manually.
>>> Isn't it become a problem for user?
>>>
>>
>> We can, that's why the NONE value for slot name was added by the patch
>> so that subscription can be made "slot-less".
> 
> Yeah, but since we can still create subscription with only NOCREATE
> SLOT option (option name will be changed but still exists), if we do
> that then non-NULL value is stored into subslotname and the
> subscription is enable. We can drop such subscription after disabled
> it and after set its slot name to NONE. But I think it's still not
> good for user..
> 

Well that's why I originally had the options directly as part of DROP
SUBSCRIPTION. But if you read the discussion in this thread, that's not
something we should be doing. There is no sensible way of mapping the
nodrop behavior to the only allowed options of RESTRICT and CASCADE so
there is not much we can do other than the ALTER.

--  Petr Jelinek                  http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Petr Jelinek
Date:
Subject: Re: [HACKERS] snapbuild woes
Next
From: tushar
Date:
Subject: [HACKERS] Issues with replication slots(which created manually) against logicalreplication