Re: Can two “SELECT FOR UPDATE” statements on the same table cause a deadlock?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Can two “SELECT FOR UPDATE” statements on the same table cause a deadlock?
Дата
Msg-id 16757.1349921393@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Can two “SELECT FOR UPDATE” statements on the same table cause a deadlock?  (Steve A <golfmat1@yahoo.com>)
Список pgsql-general
Steve A <golfmat1@yahoo.com> writes:
> In a nutshell, I'm curious about the order in which PG will lock rows during a SELECT FOR UPDATE. If two simultaneous
SELECTFOR UPDATE statements select intersecting rows from the same table, can PG be relied upon to lock the rows in a
consistentmanner that always avoids deadlock (e.g. in order of ascending primary key)? 

Only if you use ORDER BY in each such query to constrain the rows to be
locked in the same order.  You probably want to spend some time perusing
the fine manual very carefully:
http://www.postgresql.org/docs/9.2/static/sql-select.html#SQL-FOR-UPDATE-SHARE

            regards, tom lane


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

Предыдущее
От: Steve A
Дата:
Сообщение: Can two “SELECT FOR UPDATE” statements on the same table cause a deadlock?
Следующее
От: Sean Chittenden
Дата:
Сообщение: Re: 'full_page_writes=off' , VACUUM and crashing streaming slaves...