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 1ntpRv-00023z-AS for pgsql-bugs@arkaria.postgresql.org; Wed, 25 May 2022 11:45:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ntpRt-00062v-7A for pgsql-bugs@arkaria.postgresql.org; Wed, 25 May 2022 11:45:09 +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 1ntpRs-00062e-68 for pgsql-bugs@lists.postgresql.org; Wed, 25 May 2022 11:45:08 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ntpRm-0003Fh-SO for pgsql-bugs@lists.postgresql.org; Wed, 25 May 2022 11:45:07 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 5C6615C01F1; Wed, 25 May 2022 07:45:00 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 25 May 2022 07:45:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1653479100; x=1653565500; bh=K gPvqDW5YtLH2jnh9p52C4V5bwqDAbj3ahmpluiinO0=; b=ZRWV5t60nIvTZXYM5 76k9Q/3EgqUVuQjrLy5yOSKOcOrwtZ2wGMML1Kbjil2JAG7eIyCfIYkimPPuyH1c vC3Ywk1kbp/M2STuuBxWXXEahABOzOaewun5gR/1Y17/pkPT5j7z0M+68bOdokq5 hACNFJFkx6catkH2nYyX8ZZm61jSfGDZoqforUjEfkgqRmHhi2T+Ru0cPBih2tPb kcLsIIzYPyP5uMM5siTclCtifyZwzHpIeT19UA+yXp6xlzBgyQ7u4mol8UGdt+at tPe2k4Wb2Ul5ZHL0J7IxHeu2BQUqLXnpFt/Fe8M5Rx63hPaxHkanG8qSgwhQPUqu chRPA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrjeehgdegfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeejkeff gfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 25 May 2022 07:44:58 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 0DD582A1C21; Wed, 25 May 2022 13:44:54 +0200 (CEST) Date: Wed, 25 May 2022 13:44:54 +0200 From: Alvaro Herrera To: Andres Freund Cc: Andrey Borodin , Peter Geoghegan , Michael Paquier , =?utf-8?B?0J/QtdGC0YrRgCDQodC70LDQstC+0LI=?= , PostgreSQL mailing lists Subject: Re: BUG #17485: Records missing from Primary Key index when doing REINDEX INDEX CONCURRENTLY Message-ID: <202205251144.6t4urostzc3s@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220524190133.j6ee7zh4f5edt5je@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-May-24, Andres Freund wrote: > One might think that could be safe, after all the row is invisible to all > other backends. The problem is that the validation scan won't see *newer* rows > either, since they're not visible to the snapshot either. And if the new row > version is a HOT tuple, it won't have made an index entry on its own. Boom, > corruption. Whoa. My oversight here -- I failed to picture a HOT prune concurrently with CIC or RIC. > Basically snapshots don't work anymore. If PROC_IN_SAFE_IC is set, > that backend is ignored for the horizon computation for snapshots / > on-access HOT pruning. Which means that rows that are visible to the > snapshot can be pruned away. I wondered if we could have different tuple horizons for HOT pruning than for vacuum, but looking at ComputeXidHorizons() and users of that, it looks complicated to adapt. Another possibility (than reverting the commit altogether) might be to disable HOT pruning while a process is operating on that relation with PROC_IN_SAFE_IC. So CIC/RIC processes are still ignored for VACUUM, while not creating corrupted indexes. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "Postgres is bloatware by design: it was built to house PhD theses." (Joey Hellerstein, SIGMOD annual conference 2002)