pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: pgsql-hackers@lists.postgresql.org, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Andreas Karlsson <andreas@proxel.se>
Subject: Re: v12.0: interrupt reindex CONCURRENTLY: ccold: ERROR:  could not find tuple for parent of relation ...
Date: Mon, 28 Oct 2019 16:14:41 +0900
Message-ID: <20191028071441.GD1687@paquier.xyz> (raw)
In-Reply-To: <20191024045929.GD3661@paquier.xyz>
References: <20191015164047.GA22729@telsasoft.com>
	<20191024045929.GD3661@paquier.xyz>

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

Attachments:

reindex-conc-relispartition.patch (text/x-diff, 1.1K) download 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 oldIndexId, const char *oldName) newIndexTuple; Form_pg_index oldIndexForm, newIndexForm; + bool isPartition; Oid indexConstraintOid; List *constraintOids = NIL; ListCell *lc; @@ -1491,8 +1492,10 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName) namestrcpy(&newClassForm->relname, NameStr(oldClassForm->relname)); namestrcpy(&oldClassForm->relname, oldName); - /* Copy partition flag to track inheritance properly */ + /* Swap the partition flags to track inheritance properly */ + isPartition = newClassForm->relispartition; newClassForm->relispartition = oldClassForm->relispartition; + oldClassForm->relispartition = isPartition; CatalogTupleUpdate(pg_class, &oldClassTuple->t_self, oldClassTuple); CatalogTupleUpdate(pg_class, &newClassTuple->t_self, newClassTuple);
signature.asc (application/pgp-signature, 832B) download

view thread (4+ messages)  latest in thread

Message-ID: <20191028071441.GD1687@paquier.xyz>
Permalink:  ../20191028071441.GD1687@paquier.xyz/
Also on:    postgresql.org/message-id/20191028071441.GD1687@paquier.xyz

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: michael@paquier.xyz, pryzby@telsasoft.com, peter.eisentraut@2ndquadrant.com, andreas@proxel.se
  Subject: Re: v12.0: interrupt reindex CONCURRENTLY: ccold: ERROR:  could not find tuple for parent of relation ...
  In-Reply-To: <20191028071441.GD1687@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox