Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aV1VB-00054n-Dp for pgsql-hackers@arkaria.postgresql.org; Sun, 14 Feb 2016 18:34:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aV1V9-0007Qm-Ru for pgsql-hackers@arkaria.postgresql.org; Sun, 14 Feb 2016 18:34:31 +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) (envelope-from ) id 1aV1To-0005uG-5p for pgsql-hackers@postgresql.org; Sun, 14 Feb 2016 18:33:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aV1Tl-0004gx-It for pgsql-hackers@postgresql.org; Sun, 14 Feb 2016 18:33:06 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u1EIX3Zo022843; Sun, 14 Feb 2016 13:33:03 -0500 From: Tom Lane To: Robert Haas cc: "pgsql-hackers@postgresql.org" Subject: Re: [COMMITTERS] pgsql: Introduce group locking to prevent parallel processes from deadl In-reply-to: References: <27041.1455388321@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Sat, 13 Feb 2016 19:05:54 -0500" Date: Sun, 14 Feb 2016 13:33:03 -0500 Message-ID: <22842.1455474783@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 Robert Haas writes: > First, the overall concept here is that processes can either be a > member of a lock group or a member of no lock group. Check. > Second, I can review the data structure changes and the associated > invariants. The data structure additions seemed relatively straightforward, though I did wonder why you added groupLeader to PROCLOCK. Why is that not redundant with tag.myProc->lockGroupLeader? If it isn't redundant, it's inadequately documented. If it is, seems better to lose it. Also, isn't the comment on this PGPROC field incorrect: PGPROC *lockGroupLeader; /* lock group leader, if I'm a follower */ ie shouldn't you s/follower/member/ ? > ... 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. > Each PROCLOCK now has a new groupLeader flag. While a PGPROC's > lockGroupLeader may be NULL if that process is not involved in group > locking, a PROCLOCK's groupLeader always has a non-NULL value; it > points back to the PGPROC that acquired the lock. This is not what the comment on it says; and your prose explanation here implies that it should actually be equal to tag.myProc, or else you are using some definition of "acquired the lock" that I don't follow at all. There could be lots of PGPROCs that have acquired a lock in one sense or another; which one do you mean? > With respect to pg_locks - and for that matter also pg_stat_activity - > I think you are right that improvement is needed. This is really the core of my concern at the moment. I think that isolationtester is probably outright broken for any situation where the queries-under-test are being parallel executed, and so will be any other client that's trying to identify who blocks whom from pg_locks. > The simplest thing we could do to make that easier is, in > pg_stat_activity, have parallel workers advertise the PID that > launched them in a new field; and in pg_locks, have members of a lock > group advertise the leader's PID in a new field. That would be simple for us, but it would break every existing client-side query that tries to identify blockers/blockees; and not only would those queries need work but they would become very substantially more complex and slower (probably at least 4-way joins not 2-way). We already know that isolationtester's query has performance problems in the buildfarm. I think more thought is needed here, and that this area should be considered a release blocker. It's certainly a blocker for any thought of turning parallel query on by default. > I hope this helps and please let me know what more you think I should do. At the least you need to make another pass over the comments and README addition. I highlighted above a few critical inaccuracies, and it's not hard to find a lot of less-critical typos in the comments in that commit. Transposing some of what you've written here into the README would likely be a good thing too. 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