Re: CREATE INDEX CONCURRENTLY on partitioned index

From: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, 李杰(慎追) <adger(dot)lj(at)alibaba-inc(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, 曾文旌(义从) <wenjing(dot)zwj(at)alibaba-inc(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Subject: Re: CREATE INDEX CONCURRENTLY on partitioned index
Date: 2022-02-10 15:07:08
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Justin Pryzby писал 2021-02-26 21:20:
> On Mon, Feb 15, 2021 at 10:07:05PM +0300, Anastasia Lubennikova wrote:
>> 5) Speaking of documentation, I think we need to add a paragraph about
>> CIC
>> on partitioned indexes which will explain that invalid indexes may
>> appear
>> and what user should do to fix them.
> I'm not sure about that - it's already documented in general, for
> nonpartitioned indexes.


I've rebased patches and tried to fix issues I've seen. I've fixed
reference after table_close() in the first patch (can be seen while
building with CPPFLAGS='-DRELCACHE_FORCE_RELEASE'). It seems childidxs
shouldn't live in ind_context, so I moved it out of it. Updated
documentation to state that CIC can leave invalid or valid indexes on
partitions if it's not succeeded. Also merged old
0002-f-progress-reporting.patch and
0003-WIP-Add-SKIPVALID-flag-for-more-integration.patch. It seems the
first one didn't really fixed issue with progress report (as
ReindexRelationConcurrently() uses pgstat_progress_start_command(),
which seems to mess up the effect of this command in DefineIndex()).
Note, that third patch completely removes attempts to report create
index progress correctly (reindex reports about individual commands, not
the whole CREATE INDEX).

So I've added 0003-Try-to-fix-create-index-progress-report.patch, which
tries to fix the mess with create index progress report. It introduces
new flag REINDEXOPT_REPORT_CREATE_PART to ReindexParams->options. Given
this flag, ReindexRelationConcurrently() will not report about
individual operations start/stop, but ReindexMultipleInternal() will
report about reindexed partitions. To make the issue worse, some
partitions can be handled in ReindexPartitions() and
ReindexMultipleInternal() should know how many to correctly update
PROGRESS_CREATEIDX_PARTITIONS_DONE counter. Also it needs IndexOid to
correctly generate pg_stat_progress_create_index record, so we pass
these parameters to it.
Best regards,
Alexander Pyhalov,
Postgres Professional

Attachment Content-Type Size
v1-0001-Allow-CREATE-INDEX-CONCURRENTLY-on-partitioned-table.patch text/x-diff 15.3 KB
v1-0002-Add-SKIPVALID-flag-for-more-integration.patch text/x-diff 3.9 KB
v1-0003-Try-to-fix-create-index-progress-report.patch text/x-diff 7.7 KB
v1-0004-ReindexPartitions-to-set-indisvalid.patch text/x-diff 2.4 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-02-10 15:23:45 Re: faulty link
Previous Message Josef Šimánek 2022-02-10 14:54:42 Re: faulty link