pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: Re: [COMMITTERS] pgsql: Introduce group locking to prevent parallel processes from deadl
Date: Mon, 15 Feb 2016 19:55:45 -0500
Message-ID: <16815.1455584145@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+Tgmob6OM-2F+nzJyY22D0nF3WDEBvVzHgFtCnP89K=vkGcQg@mail.gmail.com>
References: <E1aSRBD-0006kV-CQ@gemulon.postgresql.org>
	<27041.1455388321@sss.pgh.pa.us>
	<CA+TgmoZZ4jDSxwYpr-EG+pxjt=3wU2UTwBQuOJ6HkmJawuZEmw@mail.gmail.com>
	<22842.1455474783@sss.pgh.pa.us>
	<CA+Tgmoazp7fh9LYFOPQ=kYk320it7ioxMuRuAO8YjVnvQVCShA@mail.gmail.com>
	<30320.1455488783@sss.pgh.pa.us>
	<CA+Tgmob6OM-2F+nzJyY22D0nF3WDEBvVzHgFtCnP89K=vkGcQg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Robert Haas <robertmhaas@gmail.com> writes:
> On Sun, Feb 14, 2016 at 5:26 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Also, after fixing that it would be good to add a comment explaining why
>> it's not fundamentally unsafe for BecomeLockGroupMember() to examine
>> leader->pgprocno without having any relevant lock.  AFAICS, that's only
>> okay because the pgprocno fields are never changed after InitProcGlobal,
>> even when a PGPROC is recycled.

> I am sort of disinclined to think that this needs a comment.

I might not either, except that the entire point of that piece of code is
to protect against the possibility that the leader PGPROC vanishes before
we can get this lock.  Since you've got extensive comments addressing that
point, it seems appropriate to explain why this one line doesn't invalidate
the whole design ... because it's right on the hairy edge of doing so.
If we did something like memset a PGPROC to all zeroes when we free it,
which in general would seem like a perfectly reasonable thing to do, this
code would be broken (and not in an easy to detect way; it would indeed
be indistinguishable from the way in which it's broken right now).

> Do we
> really have a comment every other place that pgprocno is referenced
> without a lock?

I suspect strongly that there is no other place that attempts to touch any
part of an invalid (freed) PGPROC.  If there is, more than likely it's
unsafe.

I don't have time right now to read the patch in detail, but will look
tomorrow.  In the meantime, thanks for addressing my concerns.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (25+ messages)  latest in thread

Message-ID: <16815.1455584145@sss.pgh.pa.us>
Permalink:  ../16815.1455584145@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16815.1455584145@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, pgsql-hackers@postgresql.org
  Subject: Re: [COMMITTERS] pgsql: Introduce group locking to prevent parallel processes from deadl
  In-Reply-To: <16815.1455584145@sss.pgh.pa.us>
  References: <E1aSRBD-0006kV-CQ@gemulon.postgresql.org> <27041.1455388321@sss.pgh.pa.us> <CA+TgmoZZ4jDSxwYpr-EG+pxjt=3wU2UTwBQuOJ6HkmJawuZEmw@mail.gmail.com> <22842.1455474783@sss.pgh.pa.us> <CA+Tgmoazp7fh9LYFOPQ=kYk320it7ioxMuRuAO8YjVnvQVCShA@mail.gmail.com> <30320.1455488783@sss.pgh.pa.us> <CA+Tgmob6OM-2F+nzJyY22D0nF3WDEBvVzHgFtCnP89K=vkGcQg@mail.gmail.com> <16815.1455584145@sss.pgh.pa.us>

* 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