Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsW3K-0003Ip-54 for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jul 2019 17:36:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hsW3I-0007fi-O2 for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jul 2019 17:36:44 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsW3I-0007fX-FW for pgsql-hackers@lists.postgresql.org; Tue, 30 Jul 2019 17:36:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsW3G-00078J-Ad for pgsql-hackers@postgresql.org; Tue, 30 Jul 2019 17:36:44 +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 x6UHaauv027547; Tue, 30 Jul 2019 13:36:36 -0400 From: Tom Lane To: Robert Haas cc: Michael Paquier , Andres Freund , Alvaro Herrera , PostgreSQL Hackers Subject: Re: TopoSort() fix In-reply-to: References: <20190726220538.GA17809@alvherre.pgsql> <20190726234835.xqyfukqhhzdiqoih@alap3.anarazel.de> <17997.1564187056@sss.pgh.pa.us> <20190729015059.GE6959@paquier.xyz> <23797.1564412165@sss.pgh.pa.us> <3243.1564437314@sss.pgh.pa.us> <13215.1564451308@sss.pgh.pa.us> <11847.1564496844@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Tue, 30 Jul 2019 12:46:41 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27545.1564508196.1@sss.pgh.pa.us> Date: Tue, 30 Jul 2019 13:36:36 -0400 Message-ID: <27546.1564508196@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Haas writes: > On Tue, Jul 30, 2019 at 10:27 AM Tom Lane wrote: >> (BTW, why aren't these functions just "parallel restricted"?) > ... > But it is really pretty arguable whether we should feel responsible > for that problem. We could just decide that if you're doing that, and > you don't want the scenario described above to happen, you oughta mark > the function that contains this logic at least PARALLEL RESTRICTED, > and if you don't, then it's your fault for doing a dumb thing. I > believe when we were early on in the development of this we wanted to > be very conservative lest, ah, someone accuse us of not locking things > down well enough, but maybe at this point parallel query is a > sufficiently well-established concept that we should lighten up on > some cases where we took an overly-stringent line. If we take that > view, then I'm not sure why these functions couldn't be just marked > PARALLEL SAFE. No, there's a sufficient reason why we should force advisory locks to be taken in the leader process, namely that the behavior is totally different if we don't: they will disappear at the end of the parallel worker run, not at end of transaction or session as documented. However, that argument doesn't seem to be a reason why the advisory-lock functions couldn't be parallel-restricted rather than parallel-unsafe. In any case, my question at the moment is whether we need the belt-and- suspenders-too approach of having both non-parallel-safe marking and an explicit check inside these functions. We've largely moved away from hard-wired checks for e.g. superuserness, and surely these things are less dangerous than most formerly-superuser-only functions. regards, tom lane