Re: "deadlock detected" / cascading locks

From: Matt Mello <alien(at)spaceship(dot)com>
To: Jan Wieck <JanWieck(at)Yahoo(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-sql(at)postgresql(dot)org
Subject: Re: "deadlock detected" / cascading locks
Date: 2003-05-19 20:55:05
Message-ID: 3EC944A9.1080404@spaceship.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Jan, can you explain more to a newby like me what you mean by "the
sessions set deferred modes differently?"

And, do these locks cascade? If I choose to do an update on table A,
and it has a foreign key to table B, which has a foreign key to table C,
does the update-induced lock on A cause a lock on B /and/ C?

My entire system is setup with foreign keys. Almost all of my tables
are part of a "tree" of foreign keys, which can all be traced back to
one root table. If a lock on a leaf table causes locks all the way back
to the root table, then foreign keys can't be used in my system (and it
seems they wouldn't be useful in many other systems ... where this also
true).

However, if the recent FK-lock bug fix stops this unnecessary locking,
things should work well, I guess. I have built and installed the
7.3STABLE tip, but not tested this situation yet.

Thanks again!

Jan Wieck wrote:
> Tom Lane wrote:
>
>> Matt Mello <alien(at)spaceship(dot)com> writes:
>>
>>> The two situations I can think of are:
>>> 1) Two FK fields in a single row pointing to 2 different FK tables,
>>> for which any 2 updates get locks in opposite order (seems like a
>>> deadlock).
>>
>>
>>
>> I don't think this is possible, at least in 7.3. All backends are
>> guaranteed to run the triggers of a given table in the same order,
>> so the foreign-row locks should be acquired in the same column order
>> in all cases.
>
>
> Except the sessions set deferred modes differently.
>
>
> Jan
>

--
Matt Mello

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2003-05-19 22:04:58 Re: Performance on temp table inserts
Previous Message Jan Wieck 2003-05-19 19:19:27 Re: "deadlock detected" documentation