During heap rebuild, lock any TOAST index until end of transaction.
authorNoah Misch <[email protected]>
Sat, 21 Mar 2020 16:38:26 +0000 (09:38 -0700)
committerNoah Misch <[email protected]>
Sat, 21 Mar 2020 16:38:35 +0000 (09:38 -0700)
commit978da2a95597c97c52b14a27ba29873051ffc59d
tree77dd257401417baa79df53b8e3736b0bb16ec145
parent96dffcdd5bae39fc6ffdd968a9d24b70ee8495b0
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[email protected]
src/backend/access/heap/tuptoaster.c
src/backend/commands/cluster.c