pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow a no-wait lock acquisition to succeed in more cases.
Date: Thu, 14 Mar 2024 13:15:28 +0000
Message-ID: <E1rkkvg-003lXw-9j@gemulon.postgresql.org> (raw)

Allow a no-wait lock acquisition to succeed in more cases.

We don't determine the position at which a process waiting for a lock
should insert itself into the wait queue until we reach ProcSleep(),
and we may at that point discover that we must insert ourselves ahead
of everyone who wants a conflicting lock, in which case we obtain the
lock immediately. Up until now, a no-wait lock acquisition would fail
in such cases, erroneously claiming that the lock couldn't be obtained
immediately.  Fix that by trying ProcSleep even in the no-wait case.

No back-patch for now, because I'm treating this as an improvement to
the existing no-wait feature. It could instead be argued that it's a
bug fix, on the theory that there should never be any case whatsoever
where no-wait fails to obtain a lock that would have been obtained
immediately without no-wait, but I'm reluctant to interpret the
semantics of no-wait that strictly.

Robert Haas and Jingxian Li

Discussion: http://postgr.es/m/CA+TgmobCH-kMXGVpb0BB-iNMdtcNkTvcZ4JBxDJows3kYM+GDg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2346df6fc373df9c5ab944eebecf7d3036d727de

Modified Files
--------------
src/backend/storage/lmgr/lock.c             | 119 ++++++++++++++++------------
src/backend/storage/lmgr/proc.c             |  20 ++++-
src/include/storage/proc.h                  |   4 +-
src/test/isolation/expected/lock-nowait.out |   9 +++
src/test/isolation/isolation_schedule       |   1 +
src/test/isolation/specs/lock-nowait.spec   |  28 +++++++
6 files changed, 128 insertions(+), 53 deletions(-)



Message-ID: <E1rkkvg-003lXw-9j@gemulon.postgresql.org>
Permalink:  ../E1rkkvg-003lXw-9j@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1rkkvg-003lXw-9j@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: rhaas@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Allow a no-wait lock acquisition to succeed in more cases.
  In-Reply-To: <E1rkkvg-003lXw-9j@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