Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d81r9-0005Yo-SU for pgsql-hackers@arkaria.postgresql.org; Tue, 09 May 2017 09:54:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d81r9-0007lg-FI for pgsql-hackers@arkaria.postgresql.org; Tue, 09 May 2017 09:54:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d81r8-0007lV-PG for pgsql-hackers@postgresql.org; Tue, 09 May 2017 09:54:58 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1d81r6-0000vw-0h for pgsql-hackers@postgresql.org; Tue, 09 May 2017 09:54:57 +0000 Received: by mail-wm0-x233.google.com with SMTP id u65so5086239wmu.1 for ; Tue, 09 May 2017 02:54:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=WYooUxVvywfDn/LrOORlapFuEuLiulwMNzEL4nFcFFs=; b=qGanLw8uaSWb6E04Eggij2l9Dm6utv5kYkebSHq18qJH3s+NXbkAFXi1lZipRVlwen viBcLX98fCnh+EI1WwmRwvuj1talda/AqInqsOjW1xFzvZLt4GZ3W0Tcye94rkD6BBCp UTAS242LmBAfDtde6OaVrEH73ChtALx2tvTxXOdVAvNQuAU7ypZX12cwaKZHR/vTuk1h Zv/kg7kTY2Qtp8YWnFzX407Sr6R8Hxt/asIQd9Ss1/TzLy2v5xd72XKXsflJWLmJHy8F iCCsoGvHSHt9qQfUR6p+4OjMugv5nuuDzO28kbyc3OHD7yZAvZ0/4qoUveWHmd/jG4tD uX9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=WYooUxVvywfDn/LrOORlapFuEuLiulwMNzEL4nFcFFs=; b=lp+RKCj0gorsWpnTYDE/R9X9x/nr7Bj3kCgQb4LNf2yJDXZHx6ljiUwgxSkMctXFos R7BIRTAuaUR/sS2ZWtpkULvAtPx7egI4UcxGlB3LNA1Ba+/9tCgyvlw8dbk+3k4d/TsV FxBMmucFZE5dFmT7OAFSj7hqJlFPRLaZnjNtbYdB3ms+yKi2NWl6YOsdgKsZbiv6F3gr 34w3u4rNIlzfMbahnFP005e39LVdxCUfA+3Gid6HtJ0noyyN/+6xlTAQ+gN4h0JL/Xhg AHltU9M+F7T/cWOpG9qTBh+f7zv8pIh8JbuCPGRoCmKHVI9wVOBZFDWnZfH5xaxNsP4+ duGg== X-Gm-Message-State: AODbwcAPi6iDaCmMKnOZmMGQQ9lA9fGE6sMXPJ9sbvNzt2dJyEi4AvqI 43giiYCIFsNFGdATRfeTfS3YQTDWzxirKHFPQIhIvaoMSnFy5lcv5hftVvxRXMgEGHQqjuxxiu8 wHMVmRmkQPZ6BWczKDb6dCH2jkkoqV/bhjNYKX2HiVHywc2slmkOYRbEBY8ceSfZozDGf/2Su X-Received: by 10.28.154.133 with SMTP id c127mr7078364wme.42.1494323694224; Tue, 09 May 2017 02:54:54 -0700 (PDT) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id 63sm474838wmt.9.2017.05.09.02.54.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 May 2017 02:54:53 -0700 (PDT) Subject: Re: logical replication syntax (was DROP SUBSCRIPTION, query cancellations and slot handling) To: Masahiko Sawada References: <27478.1493727233@sss.pgh.pa.us> <29431.1493730652@sss.pgh.pa.us> <360a1932-7af4-609b-94f1-2ad419430869@2ndquadrant.com> <9174dc31-787a-a2f6-818f-cb4a5c1dfddb@2ndquadrant.com> <30166.1493731904@sss.pgh.pa.us> <2b931e0e-d9f2-c79e-b74b-91df2f915e66@2ndquadrant.com> <96e95255-94d9-0881-16ba-bdb6d05bb307@2ndquadrant.com> <52a1f160-db1f-49c6-9832-498dbea58ae8@2ndquadrant.com> <35f3592b-8582-e348-1823-f8edfcf03ba3@2ndquadrant.com> <5f6ad263-af87-2aee-b86b-8bf7e3260b73@2ndquadrant.com> <3e59fc8e-fdd0-6cc5-b2c1-cf030e19e45b@2ndquadrant.com> Cc: Peter Eisentraut , Tom Lane , Robert Haas , Michael Paquier , PostgreSQL mailing lists From: Petr Jelinek Message-ID: Date: Tue, 9 May 2017 11:54:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 09/05/17 11:44, Masahiko Sawada wrote: > On Tue, May 9, 2017 at 5:57 PM, Petr Jelinek > wrote: >> On 09/05/17 10:51, Masahiko Sawada wrote: >>> On Tue, May 9, 2017 at 5:39 PM, Petr Jelinek >>> 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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers