Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iOzFF-0003WC-UM for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Oct 2019 07:15:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iOzFE-0006Bb-1y for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Oct 2019 07:15:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iOzFC-00069B-B7 for pgsql-hackers@lists.postgresql.org; Mon, 28 Oct 2019 07:15:15 +0000 Received: from [64.147.123.25] (helo=wout2-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iOzF8-0006Yw-06 for pgsql-hackers@lists.postgresql.org; Mon, 28 Oct 2019 07:15:13 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 2FFCA4E8; Mon, 28 Oct 2019 03:14:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 28 Oct 2019 03:14:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=ykHsKnWOTLGcgMMJ5S5PY7OS4O1 6A7yQkx8VfsOJFAg=; b=Jht74zYs9xefv7f1ZvJFjRP6YskFmIERzi+5Dn8UuBI aDFQ7IdcrQ7vJcJvQ7BT93yXlCJhSQY6cequ0y9Cugu9n9evHLr96VgbPKVd6iGZ aemcYHDHSzrO9i77q3347UpKRKM8Bxdxmij5CnSrOiB4XXcxJO9AnSnoMRfb5i+h C/3guKbI0fNZIUs4u84nsj/CGSsAGYk4iyAJaGVF5Ion7n2edM7hK1HFYGr65RKj q3Zk8agDy5qOelwjQfYEa6SwnNTCuYtpDSSpe/63EG9mxYyfh1wjXmx9sT6zFpdg S5hOh6mh3b8ddtM7bknWtEU+4w1LN0MtPEaljZvXoFw== 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:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=ykHsKn WOTLGcgMMJ5S5PY7OS4O16A7yQkx8VfsOJFAg=; b=NW0JeOYq20ceLrPp2Gldpp lclEMxwJax7jt3woUWr3kkrYPxfSd9ecVj8P7TDbKcOvmjwSBQa8ylIrm/hAyI3m vmlahvrqhfo9Rz5NMmPb2QrKmkj32REY+tDgkNy1o4yug6usI8sBq68PDc9B7rmI 71lbaolI56J/Gi58EzKrESbEMYfyEN6HpTub19oGYFD78sOTJ4fY8zzxQjSd2vX+ 1r+ikzeGUW0MSv5dNa6gHUZVhnNP3IlyLoAk9C4uRnpVbemf03PYYLp7uXAzhmJL +qkrs+xK7wK3gQhBj8r5s/gSAhKT+65Z8qJkLX1yAjZe1EqneZnuOlbPhXWHFI0g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrleekgddutdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucfkphepudduuddruddtvddrudektddrudekheenucfrrghr rghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiienucevlh hushhtvghrufhiiigvpedt X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 30204D6005B; Mon, 28 Oct 2019 03:14:43 -0400 (EDT) Date: Mon, 28 Oct 2019 16:14:41 +0900 From: Michael Paquier To: Justin Pryzby Cc: pgsql-hackers@lists.postgresql.org, Peter Eisentraut , Andreas Karlsson Subject: Re: v12.0: interrupt reindex CONCURRENTLY: ccold: ERROR: could not find tuple for parent of relation ... Message-ID: <20191028071441.GD1687@paquier.xyz> References: <20191015164047.GA22729@telsasoft.com> <20191024045929.GD3661@paquier.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="SnV5plBeK2Ge1I9g" Content-Disposition: inline In-Reply-To: <20191024045929.GD3661@paquier.xyz> X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.25 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --SnV5plBeK2Ge1I9g Content-Type: multipart/mixed; boundary="PPYy/fEw/8QCHSq3" Content-Disposition: inline --PPYy/fEw/8QCHSq3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Oct 24, 2019 at 01:59:29PM +0900, Michael Paquier wrote: > Yes, I can confirm the report. In the case of this scenario the > reindex is waiting for the first transaction to finish before step 5, > the cancellation causing the follow-up process to not be done > (set_dead & the next ones). So at this stage the swap has actually > happened. I am still analyzing the report in depths, but you don't > have any problems with a plain index when interrupting at this stage, > and the old index can be cleanly dropped with the new one present, so > my first thoughts are that we are just missing some more dependency > cleanup at the swap phase when dealing with a partition index. Okay, I have found this one. The issue is that at the swap phase pg_class.relispartition of the new index is updated to use the value of the old index (true for a partition index), however relispartition needs to be updated as well for the old index or when trying to interact with it we get failures as the old index is part of no inheritance trees. We could use just use false as the index created concurrently is not attached to a partition with its inheritance links updated until the swap phase, but it feels more natural to just swap relispartition for the old and the new index, as per the attached. This brings also the point that you could just update pg_class to fix things if you have a broken cluster. In short, the attached fixes the issue for me, and that's the last bug I know of in what has been reported.. -- Michael --PPYy/fEw/8QCHSq3 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="reindex-conc-relispartition.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 78896da391..f6c31ccd76 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -1462,6 +1462,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexI= d, const char *oldName) newIndexTuple; Form_pg_index oldIndexForm, newIndexForm; + bool isPartition; Oid indexConstraintOid; List *constraintOids =3D NIL; ListCell *lc; @@ -1491,8 +1492,10 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndex= Id, const char *oldName) namestrcpy(&newClassForm->relname, NameStr(oldClassForm->relname)); namestrcpy(&oldClassForm->relname, oldName); =20 - /* Copy partition flag to track inheritance properly */ + /* Swap the partition flags to track inheritance properly */ + isPartition =3D newClassForm->relispartition; newClassForm->relispartition =3D oldClassForm->relispartition; + oldClassForm->relispartition =3D isPartition; =20 CatalogTupleUpdate(pg_class, &oldClassTuple->t_self, oldClassTuple); CatalogTupleUpdate(pg_class, &newClassTuple->t_self, newClassTuple); --PPYy/fEw/8QCHSq3-- --SnV5plBeK2Ge1I9g Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl22lWEACgkQnvQgOdby QH2RUw//UE6DDr3waHtHlaFgaJmosaFeVB/WRGn6V5MPJB3VUPWOnHrWGrZM6tS9 ji7oQob7tPGeBjV8ga83E2dx3obVSx0lRo8GBT7E+Ia6tPg6MwrTp8lSZYEh8xyQ 0WhaHY5j4PHfUiyyTb85gNkp3jLPiUoefe8GLaPbhUIcKzDrwftq+XPCR5rEXqbK nFvcgoxNhpxlL5qTPfqU8IQdbdifTL5R7tZ4adMe2gCH8Y4laZ/lvS0thokgQSBx 6amaUvKvLnNyn6Ml0EaQsgGp7JmUXKFriWiZOC4EZ+rK3il0MXs5rdTKreG+sRe0 SihPmY2n7+xtzrZTHrqW5z587OY3SJXyVzkcRLj9PnJVfBww89ivJK+ql6oToi34 fNw1clCM30Cr6H9s3bmEmxb5K/KNRtOCJ3n7osY/KCgYBtJBYhlx8isrSt6Hlq6h 1IYPsW1FOvPoUeOW1Gdo4Fq/N6j7r2ilTifoy0fmD+0fRX1crQXK4Ak5lGFXuaNZ MwbbwahpTg6nhcrB6PRbiHpG6ydS1qC26j7JeAE1dKMHjgvHUScGMCb7gh67q8DX /T+10CndYpxfiTTwIawAZl70Q41QFDjLu42KYkMtN0gp1p1WJ7V3ZJams480LRgY h7Qg85XJqljlpvOvlMkrKRCyblzVVJi+hdjWtzSSMQPXEdN3hjo= =S0lX -----END PGP SIGNATURE----- --SnV5plBeK2Ge1I9g--