pgsql: Move I/O before the index_update_stats() buffer lock region. - Mailing list pgsql-committers

From Noah Misch
Subject pgsql: Move I/O before the index_update_stats() buffer lock region.
Date
Msg-id E1t7GgC-003cVs-0q@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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.b4@rfd.leadboat.com

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6c837c237bf821ee78522259c847f417d1e11fd7

Modified Files
--------------
src/backend/catalog/index.c | 54 ++++++++++++++++++++++++++++++---------------
1 file changed, 36 insertions(+), 18 deletions(-)


pgsql-committers by date:

Previous
From: Bruce Momjian
Date:
Subject: pgsql: doc: clarify text around MVCC example query
Next
From: Tom Lane
Date:
Subject: Re: pgsql: Move I/O before the index_update_stats() buffer lock region.