Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aXrV1-0004iH-Up for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Feb 2016 14:30:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aXrV0-0007fY-O7 for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Feb 2016 14:30:06 +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 1aXrUz-0007do-AL for pgsql-hackers@postgresql.org; Mon, 22 Feb 2016 14:30:05 +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 1aXrUs-0002KF-LQ for pgsql-hackers@postgresql.org; Mon, 22 Feb 2016 14:30:04 +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 u1METrrr009954; Mon, 22 Feb 2016 09:29:53 -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> <16182.1455721494@sss.pgh.pa.us> <28688.1455725891@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Mon, 22 Feb 2016 19:10:11 +0530" Date: Mon, 22 Feb 2016 09:29:53 -0500 Message-ID: <9953.1456151393@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 Wed, Feb 17, 2016 at 9:48 PM, Tom Lane wrote: >> I just had a rather disturbing thought to the effect that this entire >> design --- ie, parallel workers taking out locks for themselves --- is >> fundamentally flawed. As far as I can tell from README.parallel, >> parallel workers are supposed to exit (and, presumably, release their >> locks) before the leader's transaction commits. Releasing locks before >> commit is wrong. Do I need to rehearse why? > No, you don't. I've spent a good deal of time thinking about that problem. > [ much snipped ] > Unless I'm missing something, though, this is a fairly obscure > problem. Early release of catalog locks is desirable, and locks on > scanned tables should be the same locks (or weaker) than already held > by the master. Other cases are rare. I think. It would be good to > know if you think otherwise. After further thought, what I think about this is that it's safe so long as parallel workers are strictly read-only. Given that, early lock release after user table access is okay for the same reasons it's okay after catalog accesses. However, this is one of the big problems that we'd have to have a solution for before we ever consider allowing read-write parallelism. So what distresses me about the current situation is that this is a large stumbling block that I don't see documented anywhere. It'd be good if you transcribed some of this conversation into README.parallel. (BTW, I don't believe your statement that transferring locks back to the master would be deadlock-prone. If the lock system treats locks held by a lock group as effectively all belonging to one entity, then granting a lock identical to one already held by another group member should never fail. I concur that it might be expensive performance-wise, though it hardly seems like this would be a dominant factor compared to all the other costs of setting up and tearing down parallel workers.) 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