pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@postgresql.org
Subject: pgsql: Add API to check if an existing exclusive lock allows cleanup.
Date: Fri, 04 Nov 2016 13:32:58 +0000
Message-ID: <E1c2ec6-0007qv-1m@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Add API to check if an existing exclusive lock allows cleanup.

LockBufferForCleanup() acquires a cleanup lock unconditionally, and
ConditionalLockBufferForCleanup() acquires a cleanup lock if it is
possible to do so without waiting; this patch adds a new API,
IsBufferCleanupOK(), which tests whether an exclusive lock already
held happens to be a cleanup lock.  This is possible because a cleanup
lock simply means an exclusive lock plus the assurance any other pins
on the buffer are newer than our own pin.  Therefore, just as the
existing functions decide that the exclusive lock that they've just
taken is a cleanup lock if they observe the pin count to be 1, this
new function allows us to observe that the pin count is 1 on a buffer
we've already locked.

This is useful in situations where a backend definitely wishes to
modify the buffer and also wishes to perform cleanup operations if
possible.  The patch to eliminate heavyweight locking by hash indexes
uses this, and it may have other applications as well.

Amit Kapila, per a suggestion from me.  Some comment adjustments by me
as well.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/f2e6a2ccf1247bc15f6c03895c936b28cdeff181

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c | 49 +++++++++++++++++++++++++++++++++++++
src/include/storage/bufmgr.h        |  1 +
2 files changed, 50 insertions(+)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1c2ec6-0007qv-1m@gemulon.postgresql.org>
Permalink:  ../E1c2ec6-0007qv-1m@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1c2ec6-0007qv-1m@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: rhaas@postgresql.org
  Subject: Re: pgsql: Add API to check if an existing exclusive lock allows cleanup.
  In-Reply-To: <E1c2ec6-0007qv-1m@gemulon.postgresql.org>
  References: <E1c2ec6-0007qv-1m@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox