RowLock and multiple transactions

From: Hannes Erven <hannes(at)erven(dot)at>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: RowLock and multiple transactions
Date: 2024-02-14 22:52:03
Message-ID: 78ae159b-db92-4f03-995e-27ca75d17622@erven.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adam Fletcher 2024-02-15 02:50:42 Accessing parameters of a prepared query inside an FDW
Previous Message Tom Lane 2024-02-14 20:56:15 Re: Query regarding function cleanup in extension upgrade path