Skip to content

Commit

Permalink
Fix waits of REINDEX CONCURRENTLY for indexes with predicates or expr…
Browse files Browse the repository at this point in the history
…essions

As introduced by f9900df, a REINDEX CONCURRENTLY job done for an
index with predicates or expressions would set PROC_IN_SAFE_IC in its
MyProc->statusFlags, causing it to be ignored by other concurrent
operations.

Such concurrent index rebuilds should never be ignored, as a predicate
or an expression could call a user-defined function that accesses a
different table than the table where the index is rebuilt.

A test that uses injection points is added, backpatched down to 17.
Michail has proposed a different test, but I have added something
simpler with more coverage.

Oversight in f9900df.

Author: Michail Nikolaev
Discussion: https://postgr.es/m/CANtu0oj9A3kZVduFTG0vrmGnKB+DCHgEpzOp0qAyOgmks84j0w@mail.gmail.com
Backpatch-through: 14
(cherry picked from commit 239837a708cc2c6f27d96ddb3faf89691f2a22cd)
  • Loading branch information
michaelpq authored and shardgupta committed Dec 6, 2024
1 parent 8c1c2ba commit e54e012
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/backend/commands/indexcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -3668,8 +3668,8 @@ ReindexRelationConcurrently(Oid relationOid, ReindexParams *params)
save_nestlevel = NewGUCNestLevel();

/* determine safety of this index for set_indexsafe_procflags */
idx->safe = (indexRel->rd_indexprs == NIL &&
indexRel->rd_indpred == NIL);
idx->safe = (RelationGetIndexExpressions(indexRel) == NIL &&
RelationGetIndexPredicate(indexRel) == NIL);
idx->tableId = RelationGetRelid(heapRel);
idx->amId = indexRel->rd_rel->relam;

Expand Down

0 comments on commit e54e012

Please sign in to comment.