Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d80be6f

Browse files
committed
Fix handling of pg_class.relispartition at swap phase in REINDEX CONCURRENTLY
When cancelling REINDEX CONCURRENTLY after swapping the old and new indexes (for example interruption at step 5), the old index remains around and is marked as invalid. The old index should also be manually droppable to clean up the parent relation from any invalid indexes still remaining. For a partition index reindexed, pg_class.relispartition was not getting updated, causing the index to not be droppable as DROP INDEX would look for dependencies in a partition tree, which do not exist anymore after the swap phase is done. The fix here is simple: when swapping the old and new indexes, make sure that pg_class.relispartition is correctly switched, similarly to what is done for the index name. Reported-by: Justin Pryzby Author: Michael Paquier Discussion: https://postgr.es/m/20191015164047.GA22729@telsasoft.com Backpatch-through: 12
1 parent 8b7a0f1 commit d80be6f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/backend/catalog/index.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
14621462
newIndexTuple;
14631463
Form_pg_index oldIndexForm,
14641464
newIndexForm;
1465+
bool isPartition;
14651466
Oid indexConstraintOid;
14661467
List *constraintOids = NIL;
14671468
ListCell *lc;
@@ -1491,8 +1492,10 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
14911492
namestrcpy(&newClassForm->relname, NameStr(oldClassForm->relname));
14921493
namestrcpy(&oldClassForm->relname, oldName);
14931494

1494-
/* Copy partition flag to track inheritance properly */
1495+
/* Swap the partition flags to track inheritance properly */
1496+
isPartition = newClassForm->relispartition;
14951497
newClassForm->relispartition = oldClassForm->relispartition;
1498+
oldClassForm->relispartition = isPartition;
14961499

14971500
CatalogTupleUpdate(pg_class, &oldClassTuple->t_self, oldClassTuple);
14981501
CatalogTupleUpdate(pg_class, &newClassTuple->t_self, newClassTuple);

0 commit comments

Comments
 (0)