Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aW3f5-0008VR-2C for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Feb 2016 15:05:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aW3f4-0006tp-L5 for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Feb 2016 15:05:02 +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) (envelope-from ) id 1aW3f4-0006tj-5B for pgsql-hackers@postgresql.org; Wed, 17 Feb 2016 15:05:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aW3f0-00046e-RY for pgsql-hackers@postgresql.org; Wed, 17 Feb 2016 15:05:01 +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 u1HF4sCe016183; Wed, 17 Feb 2016 10:04:54 -0500 From: Tom Lane To: Robert Haas cc: Andres Freund , "pgsql-hackers@postgresql.org" Subject: Re: Re: [COMMITTERS] pgsql: Add some isolation tests for deadlock detection and resolution. In-reply-to: References: <21023.1455200996@sss.pgh.pa.us> <14581.1455205343@sss.pgh.pa.us> <20201.1455210279@sss.pgh.pa.us> <24444.1455251654@sss.pgh.pa.us> <1427.1455301014@sss.pgh.pa.us> <20160212232232.GA29473@awork2.anarazel.de> <1056.1455571766@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Wed, 17 Feb 2016 20:22:12 +0530" Date: Wed, 17 Feb 2016 10:04:54 -0500 Message-ID: <16182.1455721494@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: > On Tue, Feb 16, 2016 at 2:59 AM, Tom Lane wrote: >> Not to be neglected also is that (I believe) this gives the right answer, >> whereas isolationtester's existing query is currently completely broken by >> parallel queries, and it doesn't understand non-conflicting lock modes >> either. (It did, at least partially, before commit 38f8bdcac4982215; >> I am not sure that taking out the mode checks was a good idea. But >> putting them back would make the query slower yet.) > The reason I took that out is because it breaks the deadlock-soft > test. It's possible to have a situation where no granted lock > conflicts with an awaited lock. If that happens, the old query > wrongly concluded that the waiting process was not in fact waiting. > (Consider A hold AccessShareLock, B awaits AccessExclusiveLock, C now > requests AccessShareLock and *waits*.) Ah, well, with this patch the deadlock-soft test still passes. > As for the patch itself, I'm having trouble grokking what it's trying > to do. I think it might be worth having a comment defining precisely > what we mean by "A blocks B". I would define "A blocks B" in general > as either A holds a lock which conflicts with one sought by B > (hard-blocked) or A awaits a lock which conflicts with one sought by B > and precedes it in the wait queue (soft-blocked). Yes, that is exactly what I implemented ... and it's something you can't find out from pg_locks. I'm not sure how that view could be made to expose wait-queue ordering. > For parallel queries, there's a further relevant distinction when we > say "A blocks B". We might mean either that (1) process B cannot > resume execution until the lock conflict is resolved or (2) the group > leader for process B cannot complete the current parallel operation > until the lock conflict is resolved. The definition I used in this patch is "some member of A's lock group blocks some member of B's lock group", because that corresponds directly to whether A is preventing B's query from completing, which is what isolationtester wants to know --- and, I would argue, it's generally what any client would want to know. 99.9% of clients would just as soon not be aware of parallel workers lurking underneath the pg_backend_pid() values that they see for their sessions. 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