Re: Support for REINDEX CONCURRENTLY - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Support for REINDEX CONCURRENTLY
Date
Msg-id CAB7nPqRNRRYDrRmLVp0ZiE5NWP26ZiGrT3BTT-HXVo5Pz7EmBw@mail.gmail.com
Whole thread Raw
In response to Re: Support for REINDEX CONCURRENTLY  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: Support for REINDEX CONCURRENTLY
Re: Support for REINDEX CONCURRENTLY
List pgsql-hackers
I have updated the patch (v4) to take care of updating reltoastidxid for toast parent relations at the swap step by using index_update_stats. In prior versions of the patch this was done when concurrent index was built, leading to toast relations using invalid indexes if there was a failure before the swap phase. The update of reltoastidxids of toast relation is done with RowExclusiveLock.
I also added a couple of tests in src/test/isolation. Btw, as for the time being the swap step uses AccessExclusiveLock to switch old and new relnames, it does not have any meaning to run them...

On Sat, Dec 8, 2012 at 11:55 PM, Andres Freund <andres@2ndquadrant.com> wrote:
On 2012-12-08 09:40:43 -0500, Tom Lane wrote:
> Andres Freund <andres@2ndquadrant.com> writes:
> I'm tempted to propose that REINDEX CONCURRENTLY simply not try to
> preserve the index name exactly.  Something like adding or removing
> trailing underscores would probably serve to generate a nonconflicting
> name that's not too unsightly.  Or just generate a new name using the
> same rules that CREATE INDEX would when no name is specified.  Yeah,
> it's a hack, but what about the CONCURRENTLY commands isn't a hack?

I have no problem with ending up with a new name or something like
that. If that is what it takes: fine, no problem.
For the indexes that are created internally by the system like toast or internal primary keys this is acceptable. However in the case of indexes that have been created externally I do not think it is acceptable as this impacts the user that created those indexes with a specific name.

pg_reorg itself also uses the relname switch method when rebuilding indexes and people using it did not complain about the heavy lock taken at swap phase, but praised it as it really helps in reducing the lock taken for reindex at index rebuild and validation, which are the phases that take the largest amount of time in the REINDEX process btw.
--
Michael Paquier
http://michael.otacoo.com
Attachment

pgsql-hackers by date:

Previous
From: Shigeru Hanada
Date:
Subject: Re: PATCH: optimized DROP of multiple tables within a transaction
Next
From: Amit Kapila
Date:
Subject: Re: [BUG?] lag of minRecoveryPont in archive recovery