From: Justin Pryzby Date: Sun, 14 Feb 2021 18:31:43 -0600 Subject: [PATCH 2/5] f! progress reporting --- src/backend/commands/indexcmds.c | 33 +++++++------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 9ab1a66971..8f4eab22eb 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1647,40 +1647,20 @@ reindex_invalid_child_indexes(Oid indexRelationId) .options = REINDEXOPT_CONCURRENTLY }; - MemoryContext ind_context = AllocSetContextCreate(PortalContext, "CREATE INDEX", - ALLOCSET_DEFAULT_SIZES); - MemoryContext oldcontext; - List *childs = find_inheritance_children(indexRelationId, ShareLock); - List *partitions = NIL; - PreventInTransactionBlock(true, "REINDEX INDEX"); - foreach (lc, childs) + foreach (lc, find_inheritance_children(indexRelationId, ShareLock)) { Oid partoid = lfirst_oid(lc); - /* XXX: need to retrofit progress reporting into it */ - // pgstat_progress_update_param(PROGRESS_CREATEIDX_PARTITIONS_DONE, - // npart++); - - if (get_index_isvalid(partoid) || - !RELKIND_HAS_STORAGE(get_rel_relkind(partoid))) - continue; + if (!get_index_isvalid(partoid) && + RELKIND_HAS_STORAGE(get_rel_relkind(partoid))) + ReindexRelationConcurrently(partoid, ¶ms); - /* Save partition OID */ - oldcontext = MemoryContextSwitchTo(ind_context); - partitions = lappend_oid(partitions, partoid); - MemoryContextSwitchTo(oldcontext); + pgstat_progress_update_param(PROGRESS_CREATEIDX_PARTITIONS_DONE, + npart++); } - /* - * Process each partition listed in a separate transaction. Note that - * this commits and then starts a new transaction immediately. - * XXX: since this is done in 2*N transactions, it could just as well - * call ReindexRelationConcurrently directly - */ - ReindexMultipleInternal(partitions, ¶ms); - /* * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though @@ -1689,6 +1669,7 @@ reindex_invalid_child_indexes(Oid indexRelationId) * partitions. * See also: validatePartitionedIndex(). */ + CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); -- 2.17.0 --dTy3Mrz/UPE2dbVg Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0003-WIP-Add-SKIPVALID-flag-for-more-integration.patch"