Re: {CREATE INDEX, REINDEX} CONCURRENTLY improvements

From: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Michael Paquier <michael(at)paquier(dot)xyz>, James Coleman <jtc331(at)gmail(dot)com>
Subject: Re: {CREATE INDEX, REINDEX} CONCURRENTLY improvements
Date: 2020-12-04 11:38:32
Message-ID: 20201204113832.yuneqs6t4fhjo6k3@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Mon, Nov 30, 2020 at 04:54:39PM -0300, Alvaro Herrera wrote:
>
> In a previous thread [1], we added smarts so that processes running
> CREATE INDEX CONCURRENTLY would not wait for each other.
>
> One is adding the same to REINDEX CONCURRENTLY. I've attached patch
> 0002 here which does that.
>
> Why 0002, you ask? That's because preparatory patch 0001 simplifies the
> ReindexRelationConcurrently somewhat by adding a struct to be used of
> indexes that are going to be processed, instead of just a list of Oids.
> This is a good change in itself because it let us get rid of duplicative
> open/close of the index rels in order to obtain some info that's already
> known at the start.

Thanks! The patch looks pretty good to me, after reading it I only have
a few minor comments/questions:

* ReindexIndexInfo sounds a bit weird for me because of the repeating
part, although I see there is already a similar ReindexIndexCallbackState
so probably it's fine.

* This one is mostly for me to understand. There are couple of places
with a commentary that 'PROC_IN_SAFE_IC is not necessary, because the
transaction only takes a snapshot to do some catalog manipulation'.
But for some of them I don't immediately see in the relevant code
anything related to snapshots. E.g. one in DefineIndex is followed by
WaitForOlderSnapshots (which seems to only do waiting, not taking a
snapshot), index_set_state_flags and CacheInvalidateRelcacheByRelid.
Is taking a snapshot hidden somewhere there inside?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2020-12-04 11:52:03 Re: [bug fix] ALTER TABLE SET LOGGED/UNLOGGED on a partitioned table does nothing silently
Previous Message Amit Kapila 2020-12-04 11:27:04 Re: [Patch] Optimize dropping of relation buffers using dlist