Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kf3KC-0006vU-Ty for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Nov 2020 15:55:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kf3KB-0002qc-QC for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Nov 2020 15:55:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kf3KB-0002qU-JS for pgsql-hackers@lists.postgresql.org; Tue, 17 Nov 2020 15:55:19 +0000 Received: from [66.111.4.29] (helo=out5-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kf3K8-00033P-H1 for pgsql-hackers@lists.postgresql.org; Tue, 17 Nov 2020 15:55:19 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id E263D5C029C; Tue, 17 Nov 2020 10:55:04 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 17 Nov 2020 10:55:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=exVJ81P9//38fjsb+ ZAHsfern3++YoJYjTFUcJFw2H4=; b=cV3pAmWtHRHCJLEVeZQxyDq4/FIVu4AMi kjcfnzqts0QqyXatH5QoDdfFDf9QftZYaKnwvbsZJh/YPGGCnqBhTmzR61+qLH+x kcfiU7YuujqsNljCyhMgQoj7FyZF78fbyz1+ZUWj2gFWUE3c6Dp8PXVUdB4QS4ET jZNU+o+Kl6Pd0eBh5pcHRSqysWh51YaN2VPuTteOkDJXh+8907Y3we673SKp7qlm 8p6Pf3A4sRRD9c/9qj5rR++o+jeIBM7FqcYnCfU09k0ZGquOatNng/ygK5ddFjVT V3n25OHImqHc5PAZFOkpTG4e/Rncx7pdohkShBPnktq/HNvSMbaMA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudeffedgkeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdlfeehmdenucfjughrpeffhffvuffkgggtuggjfgesthdtredttder vdenucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlh hvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepvefgleevgeeujeeghfeg teeghfegheeifeehheelteetieduieeihffggfehffetnecukfhppeduledtrdelhedrud ekrdejleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.18.79]) by mail.messagingengine.com (Postfix) with ESMTPA id 4280D328005A; Tue, 17 Nov 2020 10:55:04 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id BE9FA2A1561; Tue, 17 Nov 2020 12:55:01 -0300 (-03) Date: Tue, 17 Nov 2020 12:55:01 -0300 From: Alvaro Herrera To: Tom Lane Cc: Michael Paquier , Dmitry Dolgov <9erthalion6@gmail.com>, James Coleman , Pg Hackers Subject: Re: remove spurious CREATE INDEX CONCURRENTLY wait Message-ID: <20201117155501.GA13805@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201117000832.GA19824@alvherre.pgsql> User-Agent: Mutt/1.10.1 (2018-07-13) X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.29 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Nov-16, Alvaro Herrera wrote: > On 2020-Nov-09, Tom Lane wrote: > > > Michael Paquier writes: > > >> + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); > > >> + MyProc->vacuumFlags |= PROC_IN_SAFE_IC; > > >> + ProcGlobal->vacuumFlags[MyProc->pgxactoff] = MyProc->vacuumFlags; > > >> + LWLockRelease(ProcArrayLock); > > > > > I can't help noticing that you are repeating the same code pattern > > > eight times. I think that this should be in its own routine, and that > > > we had better document that this should be called just after starting > > > a transaction, with an assertion enforcing that. > > > > Do we really need exclusive lock on the ProcArray to make this flag > > change? That seems pretty bad from a concurrency standpoint. > > BTW I now know that the reason for taking ProcArrayLock is not the > vacuumFlags itself, but rather MyProc->pgxactoff, which can move. ... ah, but I realize now that this means that we can use shared lock here, not exclusive, which is already an enormous improvement. That's because ->pgxactoff can only be changed with exclusive lock held; so as long as we hold shared, the array item cannot move.