Re: "deadlock detected" / cascading locks

Поиск
Список
Период
Сортировка
От Jan Wieck
Тема Re: "deadlock detected" / cascading locks
Дата
Msg-id 3EC97E77.40503@Yahoo.com
обсуждение исходный текст
Ответ на Re: "deadlock detected" / cascading locks  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-sql
Stephan Szabo wrote:> [...]

Yupp

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

Normally referential actions like ON DELETE CASCADE will cascade top
town, parent->child->grandchild. If an update to table A cascades
through a referential integrity constraint into an update to table B,
there is no possible deadlock through this action by itself. The primary
key colum(s) in A being updated must have a UNIQUE constraint (as per
SQL standard). Having a lock for that column(s) in A means (logically in
this context) having a lock on all referencing rows in B. So noone else
can attempt to update these rows "through this constraints referential
action".

The other way around there can be multiple path's upward from many 
tables to common RI ancestors. But the checks done do not cascade up 
since they only lock for update. With my patch they don't even do that 
"if the referencing columns did not change.


Jan

-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



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

Предыдущее
От: "Dean Gibson (DB Administrator)"
Дата:
Сообщение: Re: Testing castability of text to numeric
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Performance on temp table inserts