Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aXs01-0006Yg-UW for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Feb 2016 15:02:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aXs01-00034J-Cm for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Feb 2016 15:02:09 +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 1aXrzz-00032v-Lb for pgsql-hackers@postgresql.org; Mon, 22 Feb 2016 15:02:07 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aXrzr-00039S-VM for pgsql-hackers@postgresql.org; Mon, 22 Feb 2016 15:02:06 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 2476D5F798; Mon, 22 Feb 2016 10:01:59 -0500 (EST) Date: Mon, 22 Feb 2016 10:01:59 -0500 From: Stephen Frost To: Tom Lane Cc: Robert Haas , Andres Freund , "pgsql-hackers@postgresql.org" Subject: Re: Re: [COMMITTERS] pgsql: Add some isolation tests for deadlock detection and resolution. Message-ID: <20160222150158.GC13092@tamriel.snowman.net> References: <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> <9953.1456151393@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Sr1nOIr3CvdE5hEN" Content-Disposition: inline In-Reply-To: <9953.1456151393@sss.pgh.pa.us> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.13.0-61-generic (x86_64) X-Uptime: 09:59:16 up 201 days, 23:29, 2 users, load average: 0.08, 0.07, 0.07 User-Agent: Mutt/1.5.21 (2010-09-15) 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 --Sr1nOIr3CvdE5hEN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Tom Lane (tgl@sss.pgh.pa.us) wrote: > 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? >=20 > > No, you don't. I've spent a good deal of time thinking about that prob= lem. > > [ 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. >=20 > 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. Having such a blocker for read-write parallelism would be unfortunate, though perhaps there isn't much help for it, and having read-only query parallelism is certainly far better than nothing. > 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. Agreed. > (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.) This is only when a parallel worker is finished, no? Isn't there already some indication of when a parallel worker is done that the master handles, where it could also check the shared lock table and see if any locks were transferred to it on worker exit? Only following this thread from afar, so take my suggestions with a grain of salt. Thanks! Stephen --Sr1nOIr3CvdE5hEN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJWyyLmAAoJEO1sijiDR2RVYMwP/R6vi5BydfEDKsOHYbQG+vI0 ASgCBbWVSaVwHCbkweVs2LsKCUO3xb9yYdLyBboAMH4FGCa1nKXRVJkEVYzrFEEn gXctcyhO7/WU8aM10amkihmVM583WjoGxBIi1i+//wWgD1I89VF7hzJX2zcxHO18 33DzIQENrja7/aV4son2diidggz0qSL0EtDFyG4wvVAQVZq/r8AHp7bdM054QHOW Z3A4QcXyD/3lO8uDaYLfnNppmAKKqWQm4Cus5ML2a3MrNz+H3b01vm4Np/Y3A7D6 QKmbXyKf1pPFHW2aU3zxuspM2yrMPZmsQ647uh1KoFiSjfrzcAPJA/gtKheylrmk MQoWpcEMIEB7vpHMP4s798NyLl8EexaGws7sQrEU+Vphf9UQ0MhMksRUpwpw0iXo ZMfaRytmc1gyb6eId5tLMQpH9WCQEKbzzALdbKJGmjjZ2N3+/xY62ckwAF4vEK3i ATtJ+IHOcMMNGLUZl2ec/bHMtFnycP3ssWzgOvl5NSi5186XMh4wt45BfA7sPQnR 9zta43CO1wJT1KmPyAIArWd6hZGX3sYNREr2FX5q4vuzgYDVIWxNEzbNPW3/+t+c mKvxhe3WHgPzgjZ+QamhDrOSjNBY/+wQVlKYqLALd2bZafKUxi0TI6wkPXlhJA9G pMuS7D4sDtEnDn23wCCr =IZn2 -----END PGP SIGNATURE----- --Sr1nOIr3CvdE5hEN--