From: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> |
---|---|
To: | Hannes Erven <hannes(at)erven(dot)at>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: RowLock and multiple transactions |
Date: | 2024-02-15 07:32:24 |
Message-ID: | dc8b33cd040f2a334bc1f41ee8a2a8a7ccac37e7.camel@cybertec.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Gustafsson | 2024-02-15 08:31:32 | Re: Query regarding function cleanup in extension upgrade path |
Previous Message | David G. Johnston | 2024-02-15 05:55:01 | Re: How to do faster DML |