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 1l1b6G-0001of-HF for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Jan 2021 20:26:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l1b6F-0000UZ-E4 for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Jan 2021 20:26:07 +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 1l1b6E-0000US-J4 for pgsql-hackers@lists.postgresql.org; Mon, 18 Jan 2021 20:26:07 +0000 Received: from [66.111.4.28] (helo=out4-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1b6B-0005eH-8J for pgsql-hackers@lists.postgresql.org; Mon, 18 Jan 2021 20:26:06 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id A33455C01FE; Mon, 18 Jan 2021 15:25:51 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 18 Jan 2021 15:25:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=Yaho5xT2eRbDOrFManE2n4ha0bbw0LWcp/JJpEEMQcA=; b=KVMbzcKf R87PAO76Wu6FQVRyPo4F1pfvEpU5QRkjX9AWRbBEbQdhGkUfOhvCxGuAGxFqj2Sw F3gO8TnILp5fHBN4MD27lLdjJxiHk2HIq2QoQm9lTJ1JkOk8tftUAbp7bP2CjSid P0+p0S4A/ClOPt8GterB8BE+gSsPYSk+DIDmfNzMVgSh0dC1bka7Ailbn28Vwflf teG/nNu9oEssPCK/QaZmhl4kJPtLPVjLW58Mb/wkFRYe2dvDYTJ82VOppSVneW7p r5sS09Ke8R9sfxknV0oWYA7CbMDoa2vf5v5Xf4KwCSUyTKObRyi9wUX+YH9u1H+F lnxCTQ99Ay3OCw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrtdekgddufeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjfgesthekredttderudenucfhrhhomheplmhlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnheptefgvdevvdelueehtdeiuddutdejgffhffdugedvkeff vdektdekffeuueekveefnecukfhppeduledtrdelhedrudelrddujeejnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegr lhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.177]) by mail.messagingengine.com (Postfix) with ESMTPA id 539DD108005C; Mon, 18 Jan 2021 15:25:51 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 07D342A092A; Mon, 18 Jan 2021 17:25:49 -0300 (-03) Date: Mon, 18 Jan 2021 17:25:49 -0300 From: =?iso-8859-1?Q?=C1lvaro?= Herrera To: Matthias van de Meent Cc: Masahiko Sawada , Hamid Akhtar , PostgreSQL Hackers Subject: Re: {CREATE INDEX, REINDEX} CONCURRENTLY improvements Message-ID: <20210118202549.GA25552@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.28 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2021-Jan-18, Matthias van de Meent wrote: > Example: > > 1.) RI starts > 2.) PHASE 2: filling the index: > 2.1.) scanning the heap (live tuple is cached) > < tuple is deleted > < last transaction other than RI commits, only snapshot of RI exists > < vacuum drops the tuple, and cannot remove it from the new index > because this new index is not yet populated. > 2.2.) sorting tuples > 2.3.) index filled with tuples, incl. deleted tuple > 3.) PHASE 3: wait for transactions > 4.) PHASE 4: validate does not remove the tuple from the index, > because it is not built to do so: it will only insert new tuples. > Tuples that are marked for deletion are removed from the index only > through VACUUM (and optimistic ALL_DEAD detection). > > According to my limited knowledge of RI, it requires VACUUM to not run > on the table during the initial index build process (which is > currently guaranteed through the use of a snapshot). VACUUM cannot run concurrently with CIC or RI in a table -- both acquire ShareUpdateExclusiveLock, which conflicts with itself, so this cannot occur. I do wonder if the problem you suggest (or something similar) can occur via HOT pruning, though. -- Álvaro Herrera Valdivia, Chile