BUG #5689: UPDATE locks index before table resulting in deadlock

Поиск
Список
Период
Сортировка
От Peter Ajamian
Тема BUG #5689: UPDATE locks index before table resulting in deadlock
Дата
Msg-id 201010021223.o92CN4sB076683@wwwmaster.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #5689: UPDATE locks index before table resulting in deadlock
Список pgsql-bugs
The following bug has been logged online:

Bug reference:      5689
Logged by:          Peter Ajamian
Email address:      peter@pajamian.dhs.org
PostgreSQL version: 8.4.4
Operating system:   CentOS 5.5
Description:        UPDATE locks index before table resulting in deadlock
Details:

I got this error just now:
ERROR:  deadlock detected
DETAIL:  Process 24135 waits for AccessExclusiveLock on relation 17585 of
database 16922; blocked by process 13060.
        Process 13060 waits for RowExclusiveLock on relation 17029 of
database 16922; blocked by process 24135.
        Process 24135: REINDEX DATABASE "emailmarketer"
        Process 13060: UPDATE jobs SET lastupdatetime='1286028903' WHERE
jobid='1165'
HINT:  See server log for query details.
STATEMENT:  REINDEX DATABASE "emailmarketer"

relevant info:
emailmarketer=# select 17585::regclass, 17029::regclass;
 regclass  | regclass
-----------+----------
 jobs_pkey | jobs
(1 row)

emailmarketer=# explain UPDATE jobs SET lastupdatetime='1286028903' WHERE
jobid='1165';
                               QUERY PLAN
------------------------------------------------------------------------
 Index Scan using jobs_pkey on jobs  (cost=0.00..8.27 rows=1 width=972)
   Index Cond: (jobid = 1165)
(2 rows)

From what I can understand, the UPDATE is trying to lock the index before
locking the table.  This results in a deadlock with the REINDEX which locks
the table before the index.  UPDATE should be locking the table first which
would avoid the deadlock.

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

Предыдущее
От: Andrea Peri
Дата:
Сообщение: Postgres 9.0 crash on win7
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #5689: UPDATE locks index before table resulting in deadlock