pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hannes Erven <hannes@erven.at>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: RowLock and multiple transactions
Date: Wed, 14 Feb 2024 23:52:03 +0100
Message-ID: <78ae159b-db92-4f03-995e-27ca75d17622@erven.at> (raw)

Hi,


when "SELECT .. WHERE .. FOR NO KEY UPDATE" is used synchronize access, 
and the transaction holding the lock completes, how does PostgreSQL 
decide /which one/ of multiple waiting transactions will the lock be 
granted to next?

In my testing (on Ubuntu 16.1-1.pgdg20.04+1, 64bit) with a real-world 
application (that acquires multiple locks on a number of relations) it 
seems that it is always the transaction that attempted to lock _last_ ... ?
I thought that would most probably be random, or if it was not, the 
order would have been explained in the docs?


Thank you for any insights...
Best regards

	-hannes






view thread (2+ messages)  latest in thread

Message-ID: <78ae159b-db92-4f03-995e-27ca75d17622@erven.at>
Permalink:  ../78ae159b-db92-4f03-995e-27ca75d17622@erven.at/
Also on:    postgresql.org/message-id/78ae159b-db92-4f03-995e-27ca75d17622@erven.at

 · 

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-general@postgresql.org
  Cc: hannes@erven.at
  Subject: Re: RowLock and multiple transactions
  In-Reply-To: <78ae159b-db92-4f03-995e-27ca75d17622@erven.at>
  References: <78ae159b-db92-4f03-995e-27ca75d17622@erven.at>

* 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