Move I/O before the index_update_stats() buffer lock region.
authorNoah Misch <[email protected]>
Sat, 2 Nov 2024 16:04:55 +0000 (09:04 -0700)
committerNoah Misch <[email protected]>
Sat, 2 Nov 2024 16:05:05 +0000 (09:05 -0700)
commitbb30542976618e6d0cd9eb2358824b741566ffbf
treed70f2464da182272ba9ba6cb0638afbb7ef88937
parent4c708872950374dce23a61a1eba1411d9498d5d2
Move I/O before the index_update_stats() buffer lock region.

Commit a07e03fd8fa7daf4d1356f7cb501ffe784ea6257 enlarged the work done
here under the pg_class heap buffer lock.  Two preexisting actions are
best done before holding that lock.  Both RelationGetNumberOfBlocks()
and visibilitymap_count() do I/O, and the latter might exclusive-lock a
visibility map buffer.  Moving these reduces contention and risk of
undetected LWLock deadlock.  Back-patch to v12, like that commit.

Discussion: https://postgr.es/m/20241031200139[email protected]
src/backend/catalog/index.c