pgsql: Fix minor nbtree page deletion buffer lock issue.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix minor nbtree page deletion buffer lock issue.
Date: 2020-04-25 21:17:30
Message-ID: E1jSSB0-0002GI-F8@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix minor nbtree page deletion buffer lock issue.

Avoid accessing the deletion target page's special area during nbtree
page deletion at a point where there is no buffer lock held. This issue
was detected by a patch that extends Valgrind's memcheck tool to mark
nbtree pages that are unsafe to access (due to not having a buffer lock
or buffer pin) as NOACCESS.

We do hold a buffer pin at this point, and only access the special area,
so the old approach was safe. Even still, it seems like a good idea to
tighten up the rules in this area. There is no reason to not simply
insist on always holding a buffer lock (not just a pin) when accessing
nbtree pages.

Update some related comments in passing.

Discussion: https://postgr.es/m/CAH2-WzkLgyN3zBvRZ1pkNJThC=xi_0gpWRUb_45eexLH1+k2_Q@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/access/nbtree/nbtpage.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Geoghegan 2020-04-25 23:45:50 pgsql: Fix another minor page deletion buffer lock issue.
Previous Message Noah Misch 2020-04-25 17:27:56 pgsql: Revert "When WalSndCaughtUp, sleep only in WalSndWaitForWal()."