Re: FKs and deadlocks

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Philippe Lang" <philippe(dot)lang(at)attiksystem(dot)ch>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: FKs and deadlocks
Date: 2004-10-25 16:57:53
Message-ID: 21234.1098723473@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Philippe Lang" <philippe(dot)lang(at)attiksystem(dot)ch> writes:
> One more question: i'm surprised there are so many ExclusiveLocks when displaying pg_lock:

> 6514392 14385 ExclusiveLock t
> 6495858 11439 ExclusiveLock t
> ...etc...

Those are the transaction ID locks.

> I found in the documentation "EXCLUSIVE: This lock mode is not automatically acquired by any PostgreSQL command."

With respect to *tables* this is a true statement. For *transactions*,
the owning backend takes ExclusiveLock on its transaction ID, and any
other backend that has to wait for that transaction tries to take
ShareLock on the ID, which will block it until the ExclusiveLock is
released at transaction end. We don't use any other lock modes with
transaction IDs. (This is documented in the pg_locks view's documentation.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Hallgren 2004-10-25 17:06:40 Re: Bug or stupidity
Previous Message Alvaro Herrera 2004-10-25 16:37:34 Re: FKs and deadlocks