pgsql: Improve locking around InjectionPointRun()

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve locking around InjectionPointRun()
Date: 2024-06-28 03:33:11
Message-ID: E1sN2MI-003JWQ-Bi@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve locking around InjectionPointRun()

As coded, an injection point could be loaded into the local cache
without the LWLock InjectionPointLock taken, hence a point detached and
re-attached concurrently of a point running calling InjectionPointRun()
may finish by loading a callback it did no set initially. Based on all
the cases discussed until now on the lists, it is fine to delay the lock
release until the callback is run, so let's do that.

While on it, remove a useless LWLockRelease() called before an error in
InjectionPointAttach().

Per discussion with Heikki Linnakangas and Noah Misch.

Discussion: https://postgr.es/m/e1ffb822-054e-4006-ac06-50532767f75b@iki.fi

Branch
------
master

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

Modified Files
--------------
src/backend/utils/misc/injection_point.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2024-06-28 04:31:15 pgsql: Fix comments in heaptuple.c
Previous Message Noah Misch 2024-06-28 02:26:55 pgsql: Remove comment about xl_heap_inplace "AT END OF STRUCT".