pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Petr Jelinek <petr.jelinek@2ndquadrant.com>
To: Fujii Masao <masao.fujii@gmail.com>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Fujii Masao <fujii@postgresql.org>
Cc: pgsql-committers <pgsql-committers@postgresql.org>
Subject: Re: pgsql: Fix connection leak in DROP SUBSCRIPTION command.
Date: Wed, 22 Feb 2017 03:14:50 +0100
Message-ID: <21aee370-0d79-f678-8266-c64aed43bcf2@2ndquadrant.com> (raw)
In-Reply-To: <CAHGQGwGcq1B1NaTTGAT8=TJkjvnOmhR6JjScVVr-7y8K6R8ypw@mail.gmail.com>
References: <E1cgFIh-0007XH-Js@gemulon.postgresql.org>
	<2058.1487704345@sss.pgh.pa.us>
	<CAB7nPqQwbsUKMjoaePbJ79NzcXeqv7q_NAdC0jJ+QvHroxXS5g@mail.gmail.com>
	<CAHGQGwGcq1B1NaTTGAT8=TJkjvnOmhR6JjScVVr-7y8K6R8ypw@mail.gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

On 22/02/17 00:39, Fujii Masao wrote:
> On Wed, Feb 22, 2017 at 6:57 AM, Michael Paquier
> <michael.paquier@gmail.com> wrote:
>> On Wed, Feb 22, 2017 at 4:12 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> Fujii Masao <fujii@postgresql.org> 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



view thread (8+ messages)  latest in thread

Message-ID: <21aee370-0d79-f678-8266-c64aed43bcf2@2ndquadrant.com>
Permalink:  ../21aee370-0d79-f678-8266-c64aed43bcf2@2ndquadrant.com/
Also on:    postgresql.org/message-id/21aee370-0d79-f678-8266-c64aed43bcf2@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: petr.jelinek@2ndquadrant.com, masao.fujii@gmail.com, michael.paquier@gmail.com, tgl@sss.pgh.pa.us, fujii@postgresql.org
  Subject: Re: pgsql: Fix connection leak in DROP SUBSCRIPTION command.
  In-Reply-To: <21aee370-0d79-f678-8266-c64aed43bcf2@2ndquadrant.com>
  References: <E1cgFIh-0007XH-Js@gemulon.postgresql.org> <2058.1487704345@sss.pgh.pa.us> <CAB7nPqQwbsUKMjoaePbJ79NzcXeqv7q_NAdC0jJ+QvHroxXS5g@mail.gmail.com> <CAHGQGwGcq1B1NaTTGAT8=TJkjvnOmhR6JjScVVr-7y8K6R8ypw@mail.gmail.com> <21aee370-0d79-f678-8266-c64aed43bcf2@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox