Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d7vm1-0005yn-V9 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 May 2017 03:25:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d7vm0-0004Vf-IU for pgsql-hackers@arkaria.postgresql.org; Tue, 09 May 2017 03:25:16 +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 1d7vkT-0001mf-Gs for pgsql-hackers@postgresql.org; Tue, 09 May 2017 03:23:41 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d7vkP-00026b-Jn for pgsql-hackers@postgresql.org; Tue, 09 May 2017 03:23:39 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 978B120D1C; Mon, 8 May 2017 23:23:35 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Mon, 08 May 2017 23:23:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=uHTCA88aKYoz3NuJbc5QaQABMxJbVtD3L4eoA1USPoA=; b=UuFGyA/j zZi5rl7E8JalgWQFEMe79FRXRJLlEH06M+K4NkkKL+g48ePHtWHB9qhphZ5j+x5n DC6sowgrVCqEh6nafSz09o4QHMRqS73lbI90hqsmmk+c1aP2zuf1bqP834PnsPCI KKvsUhprZqO5K//Vo0mBOesrCiAJGtcHMyIlRn6cOY8fnZwofb4IE5oRasnP4puN kFJTUrslKO9CCwmAe95BBgCoPOEG4+k3btrTIKJSj4K0nnU96tey67ou9deLra3G la/JuzZlr3AIErxJKzeemkMo3wautYYSo24EafOE1MJ6V6gilB+S8gSGZSI2em3H 7UlLEJXb6RcVzg== X-ME-Sender: X-Sasl-enc: g5gqlqWwE82HU7opSzzuk7T71WICo59Nz+dOctTTDT/c 1494300215 Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 40809249F3; Mon, 8 May 2017 23:23:35 -0400 (EDT) Subject: Re: logical replication syntax (was DROP SUBSCRIPTION, query cancellations and slot handling) To: Petr Jelinek , Tom Lane 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> Cc: Robert Haas , Michael Paquier , PostgreSQL mailing lists From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <52a1f160-db1f-49c6-9832-498dbea58ae8@2ndquadrant.com> Date: Mon, 8 May 2017 23:23:34 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <96e95255-94d9-0881-16ba-bdb6d05bb307@2ndquadrant.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit 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 5/8/17 17:55, Petr Jelinek wrote: > On 08/05/17 22:55, Peter Eisentraut wrote: >> On 5/5/17 13:01, Petr Jelinek wrote: >>> What do you think of attached. I actually did add RESTRICT/CASCADE, in a >>> way that if there is slot RESTRICT will refuse to drop subscription and >>> CASCADE will try to drop it. Still all errors. >>> >>> The new way to not drop slot is to set slot_name to NONE which is new >>> value that I invented (inspiration from OWNED BY sequences) which >>> basically disassociates the subscription from slot. >>> >>> It's slightly less automatic this way but perhaps that's not a bad >>> thing, at least nobody will drop slots by mistake while we still make >>> sure that slots are not left over without anybody noticing. >> >> I think this is OK. Could you send a version of this patch based on >> master please? >> > > Here it is. 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. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, 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