Re: Heap lock levels for REINDEX INDEX CONCURRENTLY not quite right?

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: Heap lock levels for REINDEX INDEX CONCURRENTLY not quite right?
Дата
Msg-id 20190507032543.GH1499@paquier.xyz
обсуждение исходный текст
Ответ на Re: Heap lock levels for REINDEX INDEX CONCURRENTLY not quite right?  (Michael Paquier <michael@paquier.xyz>)
Ответы Re: Heap lock levels for REINDEX INDEX CONCURRENTLY not quite right?  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
On Tue, May 07, 2019 at 12:07:56PM +0900, Michael Paquier wrote:
> Now, what do we do about the potential deadlock issues in
> WaitForOlderSnapshots?  The attached is an isolation test able to
> reproduce the deadlock within WaitForOlderSnapshots() with two
> parallel REINDEX CONCURRENTLY.  I'd like to think that the best way to
> do that would be to track in vacuumFlags the backends running a
> REINDEX and just exclude them from GetCurrentVirtualXIDs() because
> we don't actually care about missing index entries in this case like
> VACUUM.  But it looks also to me that is issue is broader and goes
> down to utility commands which can take a lock on a table which cannot
> be run in transaction blocks, hence code paths used by CREATE INDEX
> CONCURRENTLY and DROP INDEX CONCURRENTLY could also cause a similar
> deadlock, no?

More to the point, one can just do that without REINDEX:
- session 1:
create table aa (a int);
begin;
lock aa in row exclusive mode;
- session 2:
create index concurrently aai on aa(a); --blocks
- session 3:
create index concurrently aai2 on aa(a); --blocks
- session 1:
commit;

Then session 2 deadlocks while session 3 finishes correctly.  I don't
know if this is a class of problems we'd want to address for v12, but
if we do then CIC (and DROP INDEX CONCURRENTLY?) could benefit from
it.
--
Michael

Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: reindexdb & clusterdb broken against pre-7.3 servers
Следующее
От: Dilip Kumar
Дата:
Сообщение: Re: POC: Cleaning up orphaned files using undo logs