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: Sun, 14 Feb 2016 17:05:04 -0500
Message-ID: <29381.1455487504@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+Tgmoazp7fh9LYFOPQ=kYk320it7ioxMuRuAO8YjVnvQVCShA@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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Robert Haas <robertmhaas@gmail.com> writes:
> On Sun, Feb 14, 2016 at 1:33 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Robert Haas <robertmhaas@gmail.com> writes:
>>> ... the lock manager lock that protects the fields in a
>>> given PGPROC is chosen by taking pgprocno modulo the number of lock
>>> manager partitions.
>> pgprocno of the specific PGPROC, or of the group leader? If it's
>> the former, I'm pretty suspicious that there are deadlock and/or
>> linked-list-corruption hazards here. If it's the latter, at least
>> the comments around this are misleading.
> Leader. The other way would be nuts.
On closer inspection, that's actually still somewhat problematic,
because that essentially means that no one can inspect another backend's
lockGroupLeader etc fields unless they take *all* the lock partition
LWLocks first. You can't take just the relevant one because you don't
know which one that is, at least not without dereferencing lockGroupLeader
which is entirely unsafe if you haven't got the appropriate lock.
This isn't a problem for members of the lock group, since they already
know who the leader is and hence which partition lock to use. And it's
not a problem for the deadlock detector either since it'll take all those
partition locks anyway. But it makes life difficult for status inspection
code. I'm finding that the only way to write a lock-group-aware function
that tells whether A is blocked by B is to hold both the ProcArrayLock and
*all* of the lock partition locks throughout inspection of the data
structures. I'd hoped to be able to restrict it to locking just the
partition holding the lock A is blocked on, but that ain't working.
Maybe this is all okay, but it makes me nervous that the data structures
may have been over-optimized.
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
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: <29381.1455487504@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> <29381.1455487504@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