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 1nIKtZ-0006iI-7r for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Feb 2022 01:38: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 1nIKtX-0005PW-WB for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Feb 2022 01:38:44 +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 1nIKtX-0005PN-NL for pgsql-bugs@lists.postgresql.org; Fri, 11 Feb 2022 01:38:43 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIKtV-0001CW-Gl for pgsql-bugs@lists.postgresql.org; Fri, 11 Feb 2022 01:38:43 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 4869E5C0176; Thu, 10 Feb 2022 20:38:40 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 10 Feb 2022 20:38:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; bh=St249aTBOUl4pYAUNO3WIpebrG3KOYsCI8lqlv X5JBE=; b=Rhbyw5h0eHDc/qy14TRKrjqpeTUCakNLtY0KJVlLmVumLZFWcs6wcR CThGPbsevivBuckiMd/Ma01F8RyzhD4b3ki68pkc70N4sQUFcwhjnzRtHOZzL0Jb Qlhh1k042aTd2t9hoOioi2q5jy0dh+a4N1NyxjcbjrvhySoVEWOJMRdVITpejM43 8gIfC7AZnj0194bkONne2oYuKE7VNNxF+V5Q3nW+RHFTnedWMES10Jyx1CWtj9R1 mgUiIhOJpb+4SlQkd2piRq8CiIuy2EF+SQGDPcftOuM5XmdhVxQJKRD1ptiNypmr a8ggKkENkxjtj8O+kHLFYRnAOJwkE6fw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=St249aTBOUl4pYAUN O3WIpebrG3KOYsCI8lqlvX5JBE=; b=G1nXMi8MxKSphE53FCOUehM02Y1LbsqF3 sekqIKbtqXV4sD1gzMMBm04Arg93zkMKChBBCUy8H8J+XpnWvj7bCgRCqL7I9UJR 53cShOKOW9YmfNIOsxjWjaB/UefFPAq2AJsOi07br9fp5JFq8kfNCrU0iHYl2QYX uA7o+IZ/4No1Vmgleq9kgr53DYaU9CZShzd5//fZqngDOCFkpATU2TNjhberN3m7 cnp1nR8vX1aBLaSWGHzCxufemTDtdQDP5z1vifslQxGjfnZvsxy2TglRUHIKhisU dbGOxyKpkpdmOPAzRu27myaeJiLP7McHlsTW7Q0ia6IO26ObF+30w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddriedvgdefvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepvdegudeuhfdtueeltedtveejheeh ieevueeigeelteegleejleeiueeiheegvefhnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 10 Feb 2022 20:38:37 -0500 (EST) Date: Fri, 11 Feb 2022 10:38:34 +0900 From: Michael Paquier To: Andres Freund Cc: Andrey Borodin , Ben Chobot , Peter Geoghegan , PostgreSQL mailing lists Subject: Re: BUG #17401: REINDEX TABLE CONCURRENTLY creates a race condition on a streaming replica Message-ID: References: <17401-9df851bb16dde397@postgresql.org> <49421F62-E34E-4CEA-8372-F0454DC71CA0@yandex-team.ru> <7625EC28-D102-450F-86CE-3D37095636F5@yandex-team.ru> <04D2D137-102E-400D-B66B-C073C27A1327@yandex-team.ru> <20220211001240.47idtavhfyzi4aa3@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="KRq9tZNDotKTJ6yH" Content-Disposition: inline In-Reply-To: <20220211001240.47idtavhfyzi4aa3@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --KRq9tZNDotKTJ6yH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 10, 2022 at 04:12:40PM -0800, Andres Freund wrote: > I'm pretty sure the problem is on the primary. Looking through > ReindexRelationConcurrently() I think I found at least two problems: >=20 > 1) We don't WAL log snapshot conflicts, afaict (i.e. the > WaitForOlderSnapshots() in phase 3). Which I think means that the new ind= ex > can end up being used "too soon" in pre-existing snapshots on the standby. >=20 > I don't think this is the problem this thread is about, but it's definite= ly a > problem. >=20 > 2) WaitForLockersMultiple() in phase 5 / 6 isn't WAL logged. Without wait= ing > for sessions to see the results of Phase 4, 5, we can mark the index as d= ead > (phase 5) and drop it (phase 6), while there are ongoing accesses. >=20 > I think this is the likely cause of the reported bug. Yep, I was planning to play with this problem from next week, FWIW, just lacked time/energy to do so. And the release was shipping anyway, so there is plenty of time. My impression is that we don't really need to change the WAL format based on the existing APIs we already have, or that in the worst case it would be possible to make things backward-compatible enough that it would not be a worry as long as the standbys are updated before the primaries. -- Michael --KRq9tZNDotKTJ6yH Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmIFvhoACgkQnvQgOdby QH1zjBAAqr5LsD1NQOSvjU5HXDliy/dhTS41hUF1gtkNLnMYHUGqoft0SWxAPeCE rPaBANFAs7uPXL6ddqWtHFDmEUQDyeTeou/EPGa/TXHT70PMJ95oGd/LKWyoIJY0 gmdJvbMIPsP0/Ah5s8hD9BSNb/Z2zRAiIQHWHk2KA94u6D0U6ryb3qI458GOjFJc 3Wh0S0JIDDMbQIfEoINZyJEVw4U15r3kvjXTp09YEv2cn0XGTgs8n/XiYgkkG+a2 CX8lNAjPVllfOKrdCaoMJG7lFLJzmc/7RlX4sty3P9AMnRRwH+DVg9nJaAglOs6m 9zaC3iM6F1mWYnbE7glRL7X57cbcMA4oQnhgw/edACe2Kly7O91wYlcxfg//bAYl hxbUKdmK4PiewdZVeiq52Cu/ldVABn9H0JNbHjas7mN2H9H0zLQBUmZvnmUO/RMc +MArrVDqP+Z8Ih40s2D8VTe9ReeamRrfaG6zujxGqK/obAHvl/mQsAuwAgr2OzO2 GMmAhWweJWV0exxk74SvQGpZG3+B3m6UaBwyzV8cVfiP1pXohdRwB32oTATMYvm6 QLnTQhcDJJcWETOTP+gFDMEca02x57BxyTto6lP5dJR1IaqMkMd0zZEnRIBBb4LY bFBWstDNqZ8SRHPLaxLyMzrxTfluFzNQR8LVTCUhvDJx1XBnSMw= =Idhy -----END PGP SIGNATURE----- --KRq9tZNDotKTJ6yH--