Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g6llS-00004v-3l for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Oct 2018 00:08:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g6llN-0000EX-VG for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Oct 2018 00:08:37 +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.89) (envelope-from ) id 1g6llN-0000EP-GT for pgsql-hackers@lists.postgresql.org; Mon, 01 Oct 2018 00:08:37 +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.89) (envelope-from ) id 1g6llG-0003KB-GT for pgsql-hackers@lists.postgresql.org; Mon, 01 Oct 2018 00:08:36 +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 w9108S9q027230; Sun, 30 Sep 2018 20:08:28 -0400 From: Tom Lane To: Michael Paquier cc: pgsql-hackers@lists.postgresql.org Subject: Re: Relations being opened without any lock whatever In-reply-to: <20180930232919.GC2595@paquier.xyz> References: <2038.1538335244@sss.pgh.pa.us> <20180930232919.GC2595@paquier.xyz> Comments: In-reply-to Michael Paquier message dated "Mon, 01 Oct 2018 08:29:19 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27228.1538352508.1@sss.pgh.pa.us> Date: Sun, 30 Sep 2018 20:08:28 -0400 Message-ID: <27229.1538352508@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Michael Paquier writes: > Okay, that's bad. Wouldn't it be sufficient to use what the caller > passes out as lockmode instead of enforcing AEL though? No, because at the bottom of that function we're going to do a DROP CONSTRAINT on the old FK constraint, and that needs AEL anyway. If we tried to take a lesser lock first we'd just be creating a lock-upgrade deadlock risk. regards, tom lane