Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgMSI-0000AU-Ic for pgsql-committers@arkaria.postgresql.org; Wed, 22 Feb 2017 02:14:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cgMSI-00021u-5v for pgsql-committers@arkaria.postgresql.org; Wed, 22 Feb 2017 02:14:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cgMSH-0001zn-FC for pgsql-committers@postgresql.org; Wed, 22 Feb 2017 02:14:57 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cgMSD-0005qt-P3 for pgsql-committers@postgresql.org; Wed, 22 Feb 2017 02:14:56 +0000 Received: by mail-wm0-x22d.google.com with SMTP id c85so128997887wmi.1 for ; Tue, 21 Feb 2017 18:14:53 -0800 (PST) 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=hvwdXS23q/7YD5F+kufZa5BISaIXNFDrvdt9cWzoYUI=; b=kigtFzfnXqhdHpKv/aFPraxPCqbOn0qSTX2Mvy1h9rQAirSJk4Ml1rhcaKMOPDi15Y /GRhry0RMdUOKvr7ymOqrIxU54tz54C9fgI/xt5jYgbcqgdZhO9KLz2sm8T79jTD1wVw R1kT+BM4noYqjf8EPSDldie/xwiNcpECDr0isoWUzXRipNaO8hOf9rGhOfXeFYjS/L85 pEibG2+NantSy5cDRviLM9g+fe7u8asiyg3hk903wVP7MSuKI1nPnARpFexdu/8djfZe PZht1OtXUJ72FgslQNGZgm2xYMOM9rY8iaCEX2X2Ht0Jgwh4DV36oDj5cUCJpuQVDi/y iIwQ== 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=hvwdXS23q/7YD5F+kufZa5BISaIXNFDrvdt9cWzoYUI=; b=p0TLPXqfP9Q1m9lG5z3b1wKHj8k2dGuFkZ5Yr2/7xmK2Wd5qszlM7XZyHwVBcGQoam ogKYFh9GsBpPVg/oWNsr4VgyCpDPXOXZau7GLv6Z5xi4ADHyrlphEnVP53X/Y77DWCsF 31mIh4cK5dy/wbYBr+ZOZLnWUqEf0JOyEdLIG9xcduSDULyhzrV4eR/9MagHHwpywDKZ yT66QDbW1k/hvxiKy1Ovh9bgRwi3hFSNhLdDlRl1F0ylXVx0I2yBNqwanGdNZiAhp/R7 roFAzw1MR+2YdsH3h95c9qK1sQiX2zC7vPIHBcv6B7hL6Iz+tPGc4Q4pMHYl3BQybaNa 6q8w== X-Gm-Message-State: AMke39nr+Hwv4rl60l4IEHuNEdOuLT5RMO/yMAz4kVyusNU/w8ti3wBKSwOrDxYdo05IMozKLMkLXKkdRloJlUQqHqDoJKUZGSbZSUzAyXR88bKBZgq44grDtiKFUwv4fndkD94fbETnnmV+yTIfom5ridklp6gVq9yo35JZv3QMxnka3j9K7bBrht50H/Gj/sVacFDz9C1c9dhO X-Received: by 10.28.111.75 with SMTP id k72mr145365wmc.39.1487729692783; Tue, 21 Feb 2017 18:14:52 -0800 (PST) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id v35sm9979170wrc.41.2017.02.21.18.14.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 18:14:51 -0800 (PST) Subject: Re: pgsql: Fix connection leak in DROP SUBSCRIPTION command. To: Fujii Masao , Michael Paquier References: <2058.1487704345@sss.pgh.pa.us> Cc: Tom Lane , Fujii Masao , pgsql-committers From: Petr Jelinek Message-ID: <21aee370-0d79-f678-8266-c64aed43bcf2@2ndquadrant.com> Date: Wed, 22 Feb 2017 03:14:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.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-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org On 22/02/17 00:39, Fujii Masao wrote: > On Wed, Feb 22, 2017 at 6:57 AM, Michael Paquier > wrote: >> On Wed, Feb 22, 2017 at 4:12 AM, Tom Lane wrote: >>> Fujii Masao writes: >>>> Fix connection leak in DROP SUBSCRIPTION command. >>>> Previously the command forgot to close the connection to the publisher >>>> when it failed to drop the replication slot. >>> >>> If there's a bug here, this seems like an extremely unreliable way of >>> fixing it. What if an error gets thrown before you reach that ereport? >>> >>> In other words, this coding is assuming that the walrcv_command() >>> subroutine cannot throw an error, > > Yes, but I agree that walrcv_command() may be changed in the future so that > an error is thrown and current coding is not reliable in that case. > >>> which I would consider dangerous >>> even if it were a fixed subroutine. If it's a hook that's doing >>> unknown stuff, that seems a completely untenable assumption. You >>> really need either to hook the cleanup action into normal error >>> recovery, or to use a PG_TRY block. >> >> To be honest, I have thought about using PG_ENSURE_ERROR_CLEANUP() >> when seeing the thread. If other ERROR messages are generated in the >> future that the current fix would be unreliable. > > What about the attached patch? > Looks more or less like what we do in CREATE SUBSCRIPTION for this, so I guess it's okay. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers