Re: CREATE INDEX CONCURRENTLY on partitioned index

From: Ilya Gladyshev <ilya(dot)v(dot)gladyshev(at)gmail(dot)com>
To: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>, Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, 李杰(慎追) <adger(dot)lj(at)alibaba-inc(dot)com>, 曾文旌(义从) <wenjing(dot)zwj(at)alibaba-inc(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Subject: Re: CREATE INDEX CONCURRENTLY on partitioned index
Date: 2024-05-23 21:14:57
Message-ID: 8fe0027c-a4f9-43a0-afc1-20362c159d07@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I think it's well worth the effort to revive the patch, so I rebased it
on master, updated it and will return it back to the commitfest.
Alexander, Justin feel free to add yourselves as authors

On 29.01.2024 12:43, Alexander Pyhalov wrote:
> Hi.
>
> I've rebased patch on master and it'seems to me there's one more issue -
>
> when we call DefineIndexConcurrentInternal() in partitioned case, it
> waits for transactions, locking tableId, not tabrelid - heaprelid
> LockRelId is constructed for parent index relation, not for child
> index relation.
>
> Attaching fixed version.
>
> Also I'm not sure what to do with locking of child relations. If we
> don't do anything, you can drop one of the partitioned table childs
> while CIC is in progress, and get error
>
> ERROR:  cache lookup failed for index 16399
I agree that we need to do something about it, in particular, I think we
should lock all the partitions inside the transaction that builds the
catalog entries. Fixed this in the new version.
> If you try to lock all child tables in CIC session, you'll get deadlocks.

Do you mean the deadlock between the transaction that drops a partition
and the transaction doing CIC? I think this is unavoidable and can be
reproduced even without partitioning.

Also not sure why a list of children relation was obtained with
ShareLock that CIC is supposed to avoid not to block writes, changed
that to ShareUpdateExclusive.

Regards,

Ilya

Attachment Content-Type Size
v2-0001-Allow-CREATE-INDEX-CONCURRENTLY-on-partitioned-ta.patch text/x-patch 23.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Karki, Sanjay 2024-05-23 22:01:41 PG catalog
Previous Message Bertrand Drouvot 2024-05-23 21:12:28 Re: Avoid orphaned objects dependencies, take 3