Re: "deadlock detected" / cascading locks

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: "deadlock detected" / cascading locks
Дата
Msg-id 20030519152242.G42425-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Re: "deadlock detected" / cascading locks  (Matt Mello <alien@spaceship.com>)
Список pgsql-sql
On Mon, 19 May 2003, Matt Mello wrote:

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

If a constraint is deferred in one transaction and not in another the
order the locks are grabbed could be different.  For example you have two
constraints A and B, and two transactions T1 and T2.  T1 sets constraint A
to be deferred, T2 has constraint A being immediate. T1 will get the lock
for B first (at end of statement) and then get lock A second (at end of
transaction).  T2 will get lock A first (at end of statement) and B second
(at end of statement).  This could cause deadlock if both transactions do
something that locks the same rows for A and B and T1 gets the B lock,
then T2 gets the A lock, then T2 waits on T1 for the B lock, then T1 waits
for T2 on the A lock when it goes to commit.

> 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?

Not for checks since those don't change the table in question.  It's
possible for locks to cascade through referential action effects (although
that effect is partially minimized by the bug fix mentioned for
update unless the referencing column is itself the one being referenced)



В списке pgsql-sql по дате отправления:

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: Performance on temp table inserts
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: CASE