aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2024-10-28 16:44:31 -0500
committerNathan Bossart <nathan@postgresql.org>2024-10-28 16:44:31 -0500
commit70b9adb98eab42bc12ddeea863be335b21b55675 (patch)
tree739b33d41148acf62387cf8bad2882002134d27c
parent11b7de4a784135d7a9bce4a29ede092797749efc (diff)
downloadpostgresql-70b9adb98eab42bc12ddeea863be335b21b55675.tar.gz
postgresql-70b9adb98eab42bc12ddeea863be335b21b55675.zip
Ensure we have a snapshot when updating pg_index in index_drop().
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 Sawada Reviewed-by: Stepan Neretin, Masahiko Sawada Discussion: https://postgr.es/m/CAD21AoBgF9etQrXbN9or_YHsmBRJHHNUEkhHp9rGK9CyQv5aTQ%40mail.gmail.com
-rw-r--r--src/backend/catalog/index.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 9162b9f81a2..74d0f3097eb 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -2336,13 +2336,9 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
/*
* 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
@@ -2361,8 +2357,7 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
ReleaseSysCache(tuple);
table_close(indexRelation, RowExclusiveLock);
- if (concurrent)
- PopActiveSnapshot();
+ PopActiveSnapshot();
/*
* if it has any expression columns, we might have stored statistics about