During heap rebuild, lock any TOAST index until end of transaction.

Noah Misch <noah@leadboat.com>

Commit: 88b3a6cd262344f5de64eab31804a0f39a7c6337
Author: Noah Misch <noah@leadboat.com>
Date: 2020-03-21T16:38:30Z
Releases: 12.3
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

Files

PathChange+/−
src/backend/access/heap/tuptoaster.c modified +2 −2
src/backend/commands/cluster.c modified +1 −1

Discussion