Re: Deadlock between concurrent index builds on different tables

Поиск
Список
Период
Сортировка
От Martin Marques
Тема Re: Deadlock between concurrent index builds on different tables
Дата
Msg-id e7248be4-3c52-7b91-283d-f35f650882dc@2ndquadrant.com
обсуждение исходный текст
Ответ на Deadlock between concurrent index builds on different tables  (Jeremy Finzel <finzelj@gmail.com>)
Ответы Re: Deadlock between concurrent index builds on different tables  (Jeremy Finzel <finzelj@gmail.com>)
Список pgsql-general
El 22/12/17 a las 18:53, Jeremy Finzel escribió:
> I am attempting to build several indexes in parallel, guaranteeing that
> I never build one on the same table twice.  I understand I can't build
> two on the same table at once or I will get a deadlock.  However, I am
> also getting a deadlock when doing several in parallel on different tables.

On the same table you wouldn't get a dead lock as CREATE INDEX
CONCURRENTLY takes a "share update exclusive lock" which is incompatible
with vacuum and schema changes (and stronger locks), and a second CREATE
INDEX CONCURRENTLY would be another schema change.

So the first one would lock the second, which will have to wait until
completion of the locking statement.

> Here is an example of the error I am getting:
> 
> 2017-12-22 15:48:07.669 CST,"CREATE INDEX",2017-12-22 15:48:02
> CST,8/32,0,ERROR,40P01,"deadlock detected","Process 4470 waits for
> ShareLock on virtual transaction 4/262; blocked by process 4466.
> Process 4466 waits for ShareLock on virtual transaction 8/32; blocked by
> process 4470.
> Process 4470: CREATE INDEX CONCURRENTLY index_foo_on_created_at ON foo
> USING btree (created_at);
> Process 4466: CREATE INDEX CONCURRENTLY index_bar_on_id ON bar USING
> btree (id);","See server log for query details.",,,,"CREATE INDEX
> CONCURRENTLY index_foo_on_created_at ON foo USING btree (created_at);",,,""

The only thing I can think of is that there's a foreign key from foo to
bar(id), but the create index on bar shouldn't prevent a share lock on
foo, even if such a restriction exists.

-- 
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


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

Предыдущее
От: Martin Marques
Дата:
Сообщение: Re: Deadlock between concurrent index builds on different tables
Следующее
От: Martin Marques
Дата:
Сообщение: Re: Stand by server (9.6.6) with corrupt file