Re: LWLockAcquire and LockBuffer mode argument - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: LWLockAcquire and LockBuffer mode argument
Date
Msg-id CAH2-WzkwdOyYURjfE_tWuqqtfmb4r79MwYrXN-yL7W23V+vCcA@mail.gmail.com
Whole thread Raw
In response to LWLockAcquire and LockBuffer mode argument  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Mon, Aug 24, 2020 at 3:35 PM Andres Freund <andres@anarazel.de> wrote:
> To avoid unnecessary backward compat pains it seems best to first
> introduce compat wrappers using the current signature, and then
> subsequently replace in-core callers with the direct calls.

I like the idea of doing this, purely to make profiler output easier
to interpret.

Passing a shared-or-exclusive flag is kind of a natural thing to do
within code like _bt_search(), where we sometimes want to
exclusive-lock the leaf level page but not the internal pages that we
descend through first. Fortunately we can handle the flag inside the
existing nbtree wrapper functions quite easily -- the recently added
_bt_lockbuf() can test the flag directly. We already have
nbtree-private flags (BT_READ and BT_WRITE) that we can continue to
use after the old interface is fully deprecated.

More generally, it probably is kind of natural to have a flag like
BUFFER_LOCK_SHARE/BUFFER_LOCK_EXCLUSIVE (though not like
BUFFER_LOCK_UNLOCK) within index access methods. But I think that
there are several good reasons to add something equivalent to
_bt_lockbuf() to all index access methods.

-- 
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: LWLockAcquire and LockBuffer mode argument
Next
From: Bruce Momjian
Date:
Subject: Re: Missing "Up" navigation link between parts and doc root?