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

Commit 70b9adb

Browse files
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 b52adba. Reported-by: Masahiko Sawada Reviewed-by: Stepan Neretin, Masahiko Sawada Discussion: https://postgr.es/m/CAD21AoBgF9etQrXbN9or_YHsmBRJHHNUEkhHp9rGK9CyQv5aTQ%40mail.gmail.com
1 parent 11b7de4 commit 70b9adb

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/backend/catalog/index.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,13 +2336,9 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
23362336

23372337
/*
23382338
* Updating pg_index might involve TOAST table access, so ensure we have a
2339-
* valid snapshot. We only expect to get here without a snapshot in the
2340-
* concurrent path.
2339+
* valid snapshot.
23412340
*/
2342-
if (concurrent)
2343-
PushActiveSnapshot(GetTransactionSnapshot());
2344-
else
2345-
Assert(HaveRegisteredOrActiveSnapshot());
2341+
PushActiveSnapshot(GetTransactionSnapshot());
23462342

23472343
/*
23482344
* fix INDEX relation, and check for expressional index
@@ -2361,8 +2357,7 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
23612357
ReleaseSysCache(tuple);
23622358
table_close(indexRelation, RowExclusiveLock);
23632359

2364-
if (concurrent)
2365-
PopActiveSnapshot();
2360+
PopActiveSnapshot();
23662361

23672362
/*
23682363
* if it has any expression columns, we might have stored statistics about

0 commit comments

Comments
 (0)