pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedRowLock and multiple transactions
2+ messages / 2 participants
[nested] [flat]
* RowLock and multiple transactions
@ 2024-02-14 22:52 Hannes Erven <hannes@erven.at>
0 siblings, 1 reply; 2+ messages in thread
From: Hannes Erven @ 2024-02-14 22:52 UTC (permalink / raw)
To: pgsql-general
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: RowLock and multiple transactions
@ 2024-02-15 07:32 Laurenz Albe <laurenz.albe@cybertec.at>
parent: Hannes Erven <hannes@erven.at>
0 siblings, 0 replies; 2+ messages in thread
From: Laurenz Albe @ 2024-02-15 07:32 UTC (permalink / raw)
To: Hannes Erven <hannes@erven.at>; pgsql-general
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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2024-02-15 07:32 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-02-14 22:52 RowLock and multiple transactions Hannes Erven <hannes@erven.at>
2024-02-15 07:32 ` Laurenz Albe <laurenz.albe@cybertec.at>
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