pgsql: Move I/O before the index_update_stats() buffer lock region.

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Move I/O before the index_update_stats() buffer lock region.
Date: 2024-11-02 16:08:47
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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/[email protected]

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d729f1ea5a46963f3d4b0dd1268f3583b1cdbe9e

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

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2024-11-03 02:32:56 Re: pgsql: Move I/O before the index_update_stats() buffer lock region.
Previous Message Bruce Momjian 2024-11-01 20:38:44 pgsql: doc: clarify text around MVCC example query