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 1keoY9-0006pX-H2 for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Nov 2020 00:08:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1keoY8-0001jE-Dk for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Nov 2020 00:08:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1keoY7-0001gL-CI for pgsql-hackers@lists.postgresql.org; Tue, 17 Nov 2020 00:08:44 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1keoY0-0007gl-ST for pgsql-hackers@lists.postgresql.org; Tue, 17 Nov 2020 00:08:42 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 8E2F35C0238; Mon, 16 Nov 2020 19:08:35 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 16 Nov 2020 19:08:35 -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=i/rp5/nV3Wv86BCaj +UxLIY41kQc4rLK4CLURJXzDBM=; b=AgC5htbsgLcb7SMEu3xCbviHLZbTqCfIg 3nmliGn/3K+Fbyhx+/XaTmlgThQYIvgz/ukeSw2UY9qCwllmM1lRSyHJO3bY2aIK CN2uT1wu3zPFU9B3/oAQ1XsG6LOkxh57mIHmzY05vmhugHhFqg94rlTJu4+RhA9K wG3qGqq7PVPv6rifV4xRUckR8Jgu94KJCFxgqCpm7lCHaVJVqydS7lhcvEvnMS62 92m1ifj8Ac62SmFyn1hf0ArBV6Ci9s4+NMYMUw7ORdX2ca/16E1vy2hlBKaZmrZy REWzy1RxzEUh2MrWXIUKntKs2rjoza6J4YrSGnEw7eQCoTz1nbVDQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudefvddgudeiucetufdoteggodetrfdotf 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 D71C63064AAE; Mon, 16 Nov 2020 19:08:34 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 960232A1561; Mon, 16 Nov 2020 21:08:32 -0300 (-03) Date: Mon, 16 Nov 2020 21:08:32 -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: <20201117000832.GA19824@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2087667.1604971933@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. On the other hand, if we stopped mirroring the flags in ProcGlobal, it would mean we would have to access all procs' PGPROC entries in GetSnapshotData, which is undesirable for performance reason (per commit 5788e258bb26).