Order of locking in postgres SELECT FOR UPDATE

From: Eric Springer <ericwspringer(at)gmail(dot)com>
To: pgeu-general(at)postgresql(dot)org
Subject: Order of locking in postgres SELECT FOR UPDATE
Date: 2015-03-14 16:59:07
Message-ID: CAHD7LM3Tgupt7PiG9mQrOai5HL0FioAs8ceZ8o8NXWte0eQZ7g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgeu-general

I asked the question on Stack Overflow:
http://stackoverflow.com/questions/29041327/order-of-locking-in-postgres-select-for-update

but haven't got any answers, so reposting it here:

Assuming both table a and b has a single row, the query:

SELECT * FROM a, b FOR UPDATE

should get two row-level locks (one on a, one on b). Is there any
defined ordering in which the locks are acquired? And is there any way
to require the lock from the table b to get acquired lock before the
one from a (to avoid deadlocking with other transactions)?

Responses

Browse pgeu-general by date

  From Date Subject
Next Message Oliver Elphick 2015-03-15 06:30:54 Re: Order of locking in postgres SELECT FOR UPDATE
Previous Message Daniel Gustafsson 2015-02-18 11:13:16 Re: PostgreSQL Europe Elections 2015: Results available