Skip to content

Commit 239837a

Browse files
committed
Fix waits of REINDEX CONCURRENTLY for indexes with predicates or expressions
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
1 parent f37ac61 commit 239837a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/commands/indexcmds.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3668,8 +3668,8 @@ ReindexRelationConcurrently(Oid relationOid, ReindexParams *params)
36683668
save_nestlevel = NewGUCNestLevel();
36693669

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

0 commit comments

Comments
 (0)