I assumed that all index_drop() callers set an active snapshot
beforehand, but that is evidently not true. One counterexample is
autovacuum, which doesn't set an active snapshot when cleaning up
orphan temp indexes. To fix, unconditionally push an active
snapshot before updating pg_index in index_drop().
Oversight in commit
b52adbad46.
Reported-by: Masahiko SawadaReviewed-by: Stepan Neretin, Masahiko SawadaDiscussion: https://postgr.es/m/CAD21AoBgF9etQrXbN9or_YHsmBRJHHNUEkhHp9rGK9CyQv5aTQ%40mail.gmail.com
/*
* Updating pg_index might involve TOAST table access, so ensure we have a
- * valid snapshot. We only expect to get here without a snapshot in the
- * concurrent path.
+ * valid snapshot.
*/
- if (concurrent)
- PushActiveSnapshot(GetTransactionSnapshot());
- else
- Assert(HaveRegisteredOrActiveSnapshot());
+ PushActiveSnapshot(GetTransactionSnapshot());
/*
* fix INDEX relation, and check for expressional index
ReleaseSysCache(tuple);
table_close(indexRelation, RowExclusiveLock);
- if (concurrent)
- PopActiveSnapshot();
+ PopActiveSnapshot();
/*
* if it has any expression columns, we might have stored statistics about