From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Hannes Erven <hannes@erven.at>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: RowLock and multiple transactions
Date: Thu, 15 Feb 2024 08:32:24 +0100
Message-ID: <dc8b33cd040f2a334bc1f41ee8a2a8a7ccac37e7.camel@cybertec.at> (raw)
In-Reply-To: <78ae159b-db92-4f03-995e-27ca75d17622@erven.at>
References: <78ae159b-db92-4f03-995e-27ca75d17622@erven.at>
On Wed, 2024-02-14 at 23:52 +0100, Hannes Erven wrote:
> 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?
Transactions queue behind a lock, and they get the lock in a "first come,
first served" order.
Yours,
Laurenz Albe
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: laurenz.albe@cybertec.at, hannes@erven.at
Subject: Re: RowLock and multiple transactions
In-Reply-To: <dc8b33cd040f2a334bc1f41ee8a2a8a7ccac37e7.camel@cybertec.at>
References: <78ae159b-db92-4f03-995e-27ca75d17622@erven.at> <dc8b33cd040f2a334bc1f41ee8a2a8a7ccac37e7.camel@cybertec.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