Re: BUG #13523: Unexplained deadlocks (possible race condition)

Поиск
Список
Период
Сортировка
От Jack Douglas
Тема Re: BUG #13523: Unexplained deadlocks (possible race condition)
Дата
Msg-id 01b001d0c960$894af9e0$9be0eda0$@douglastechnology.co.uk
обсуждение исходный текст
Ответ на Re: BUG #13523: Unexplained deadlocks (possible race condition)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
> I believe the issue with this is that a SQL function will do parsing (and
maybe planning too; don't feel like checking the code right now) for the
entire function body at once.  This means that due to the INSERT command you
acquire RowExclusiveLock on the "test" table during function body parsing,
before the LOCK command actually executes.  So the LOCK represents a lock
escalation attempt, and deadlocks are to be expected.

That makes perfect sense, many thanks for the explanation.

> This coding technique would be safe in plpgsql, but not in a SQL-language
function.

That's useful to know - I already worked around the issue with a retry-loop
(as I'm basically doing an upsert the 'bad' way with `lock table` - roll on
9.5!)

Kind regards
Jack

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #13523: Unexplained deadlocks (possible race condition)
Следующее
От: Kevin Grittner
Дата:
Сообщение: Re: BUG #13518: CancelRequest lacks statement identifier