summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2020-03-21 09:38:26 -0700
committerNoah Misch <noah@leadboat.com>2020-03-21 09:38:34 -0700
commit78a34c68920a544292d54f60af561c267b95f64d (patch)
treeda395b1a4819610e9ee1f96c50e16fadfad867fb /src
parent40348680003d637e2068fd4981216f51bff8762b (diff)
During heap rebuild, lock any TOAST index until end of transaction.
swap_relation_files() calls toast_get_valid_index() to find and lock this index, just before swapping with the rebuilt TOAST index. The latter function releases the lock before returning. Potential for mischief is low; a concurrent session can issue ALTER INDEX ... SET (fillfactor = ...), which is not alarming. Nonetheless, changing pg_class.relfilenode without a lock is unconventional. Back-patch to 9.5 (all supported versions), because another fix needs this. Discussion: https://postgr.es/m/20191226001521.GA1772687@rfd.leadboat.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/heap/tuptoaster.c4
-rw-r--r--src/backend/commands/cluster.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c
index e3d09db0a85..04edfda5b41 100644
--- a/src/backend/access/heap/tuptoaster.c
+++ b/src/backend/access/heap/tuptoaster.c
@@ -1447,8 +1447,8 @@ toast_get_valid_index(Oid toastoid, LOCKMODE lock)
validIndexOid = RelationGetRelid(toastidxs[validIndex]);
/* Close the toast relation and all its indexes */
- toast_close_indexes(toastidxs, num_indexes, lock);
- heap_close(toastrel, lock);
+ toast_close_indexes(toastidxs, num_indexes, NoLock);
+ heap_close(toastrel, NoLock);
return validIndexOid;
}
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index fe2d4f147d7..69dbaf3b8d4 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -1636,7 +1636,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
/* Get the associated valid index to be renamed */
toastidx = toast_get_valid_index(newrel->rd_rel->reltoastrelid,
- AccessShareLock);
+ NoLock);
/* rename the toast table ... */
snprintf(NewToastName, NAMEDATALEN, "pg_toast_%u",