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 1g6yGN-0007FK-NK for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Oct 2018 13:29:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g6yGL-0000wx-LJ for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Oct 2018 13:29:25 +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.89) (envelope-from ) id 1g6yGL-0000wq-EQ for pgsql-hackers@lists.postgresql.org; Mon, 01 Oct 2018 13:29:25 +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.89) (envelope-from ) id 1g6yGJ-0007Mx-Fm for pgsql-hackers@lists.postgresql.org; Mon, 01 Oct 2018 13:29:25 +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 w91DTIiT021005; Mon, 1 Oct 2018 09:29:19 -0400 From: Tom Lane To: Amit Langote cc: pgsql-hackers@lists.postgresql.org Subject: Re: Relations being opened without any lock whatever In-reply-to: References: <2038.1538335244@sss.pgh.pa.us> Comments: In-reply-to Amit Langote message dated "Mon, 01 Oct 2018 16:19:58 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21003.1538400558.1@sss.pgh.pa.us> Date: Mon, 01 Oct 2018 09:29:18 -0400 Message-ID: <21004.1538400558@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Amit Langote writes: > On 2018/10/01 4:20, Tom Lane wrote: >> Running the regression tests with the patch I showed in >> https://www.postgresql.org/message-id/16565.1538327894@sss.pgh.pa.us > Maybe you've noticed but the relation_open calls coming from bootstrap.c > all pass NoLock which trigger the WARNING: Yeah, I'd missed noticing that at the time I posted that patch, but I sure noticed after changing the WARNING to an Assert ;-) > Do we need to do something about that, like teaching boot_openrel() and > gettype() in bootstrap.c to pass AccessShareLock instead of NoLock? No, bootstrap mode has no need for locking. I think the right fix is just to skip the check: + /* + * If we didn't get the lock ourselves, assert that caller holds one, + * except in bootstrap mode where no locks are used. + */ + Assert(lockmode != NoLock || + IsBootstrapProcessingMode() || + CheckRelationLockedByMe(r, AccessShareLock, true)); It's possible that at some point we'd decide to make bootstrap mode do locking the same as normal mode, but that's not a change I want to make as part of this patch. regards, tom lane