From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | twoflower <standa(dot)kurik(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: SELECT blocks UPDATE |
Date: | 2015-08-13 23:58:06 |
Message-ID: | 29040.1439510286@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
twoflower <standa(dot)kurik(at)gmail(dot)com> writes:
> Tom Lane-2 wrote
>> So either the SELECT is a SELECT FOR UPDATE, or it's part of a transaction
>> that's done datachanges in the past.
> If these are the only two explanations, it must be the latter then. What I
> still don't understand - these two statements are part of the same
> transaction (because the lock query joins on the lock's transaction id), so
> it looks like a transaction blocking itself. As I think about it now, it
> does not even make sense to me /why/ the lock query joins on the
> lock.transactionid - I would expect two locks will mostly conflict with each
> other when they are executed within /different/ transactions.
No, you're misunderstanding the meaning of the column. virtualtransaction
and pid are what identify the session that is holding/awaiting a lock.
A transactionid is something that a lock can be taken on, and if you have
a session that is awaiting such a lock then it's waiting for the session
doing that transaction to end its transaction.
The use of such locks in Postgres is pretty narrow, though. AFAIR this
would only happen in the context of a session waiting to acquire a row
lock on a row that it's trying to update/delete/lock for update.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Feyrer | 2015-08-14 00:03:46 | Foreign Keys as first class citizens at design time? |
Previous Message | Adrian Klaver | 2015-08-13 21:20:02 | Re: SELECT blocks UPDATE |