Skip to content

Commit 2ee2632

Browse files
author
Antonin Houska
committed
Fixed locking of TOAST indexes.
Problem introduced by commit aceb16a.
1 parent 06f58ae commit 2ee2632

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pg_squeeze.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,10 +3219,11 @@ swap_toast_names(Oid relid1, Oid toastrelid1, Oid relid2, Oid toastrelid2)
32193219

32203220
snprintf(name, NAMEDATALEN, "pg_toast_%u_index_", relid1);
32213221
#if PG_VERSION_NUM < 130000
3222+
/* NoLock as RenameRelationInternal() did not release its lock. */
32223223
toastidxid = get_toast_index(toastrelid2);
32233224
#else
3224-
/* NoLock as RenameRelationInternal() did not release its lock. */
3225-
toastidxid = toast_get_valid_index(toastrelid2, NoLock);
3225+
/* TOAST relation is locked, but not its indexes. */
3226+
toastidxid = toast_get_valid_index(toastrelid2, AccessExclusiveLock);
32263227
#endif
32273228
/*
32283229
* Pass is_index=false so that even the index is locked in
@@ -3240,9 +3241,11 @@ swap_toast_names(Oid relid1, Oid toastrelid1, Oid relid2, Oid toastrelid2)
32403241
RenameRelationInternal(toastrelid1, name, true, false);
32413242
/* NoLock as RenameRelationInternal() did not release its lock. */
32423243
#if PG_VERSION_NUM < 130000
3244+
/* NoLock as RenameRelationInternal() did not release its lock. */
32433245
toastidxid = get_toast_index(toastrelid1);
32443246
#else
3245-
toastidxid = toast_get_valid_index(toastrelid1, NoLock);
3247+
/* TOAST relation is locked, but not its indexes. */
3248+
toastidxid = toast_get_valid_index(toastrelid1, AccessExclusiveLock);
32463249
#endif
32473250
snprintf(name, NAMEDATALEN, "pg_toast_%u_index", relid1);
32483251
RenameRelationInternal(toastidxid, name, true, false);

0 commit comments

Comments
 (0)