Re: Strange deadlock in foreign key check

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Strange deadlock in foreign key check
Дата
Msg-id 20150806151135.GN2441@postgresql.org
обсуждение исходный текст
Ответ на Strange deadlock in foreign key check  (Sophia Wright <sjw9010@gmail.com>)
Ответы Re: Strange deadlock in foreign key check  (Sophia Wright <sjw9010@gmail.com>)
Список pgsql-general
Sophia Wright wrote:
> I am seeing some odd locking behaviour when deleting a parent record
> (Postgres 9.4.4).

Somewhere in the triggers for FK checks we do "SELECT FOR KEY SHARE" of
the PK tuples when the FK tuples are altered; and conversely when we
remove tuples from the PK side we need to ensure that there are no
referencing tuples in the FK side.  The code doesn't distinguish between
indexes used in foreign keys from other indexes that *could* be used in
foreign keys.  Therefore your UNIQUE in the declaration for "x" may be
making it difficult for you.  I don't have the time to go through this
right now, but please try and see what happens if you remove the UNIQUE
from that column.

We discussed about only considering indexes actually referenced by
foreign keys instead of all of them, but there are some fine points to
keep in mind if you do that, so we never got around to implementing that
optimization.  I don't have any immediate suggestion for what to do to
work around this issue.

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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

Предыдущее
От: Sophia Wright
Дата:
Сообщение: Strange deadlock in foreign key check
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Strange deadlock in foreign key check