Re: [GENERAL] Using an SMP machine to make multiple indices on the same

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [GENERAL] Using an SMP machine to make multiple indices on the same
Дата
Msg-id 21521.1003945761@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [GENERAL] Using an SMP machine to make multiple indices on the same  ("Hiroshi Inoue" <Inoue@tpf.co.jp>)
Список pgsql-hackers
"Hiroshi Inoue" <Inoue@tpf.co.jp> writes:
> In the end, I changed DefineIndex() to not call IndexesAreActive().

I saw that.  But is it a good solution?  If someone has deactivated
indexes on a user table (ie turned off relhasindex), then creating a
new index would activate them again, which would probably be bad.

I have realized that this code is wrong anyway, because it doesn't
acquire ShareLock on the relation until far too late; all the setup
processing is done with no lock at all :-(.  LockClassinfoForUpdate
provided a little bit of security against concurrent schema changes,
though not enough.

Also, I'm now a little worried about whether concurrent index creations
will actually work.  Both CREATE INDEX operations will try to update
the pg_class tuple to set relhasindex true.  Since they use
simple_heap_update for that, the second one is likely to fail
because simple_heap_update doesn't handle concurrent updates.

I think what we probably want is
1. Acquire ShareLock at the very start.
2. Check for indexes present but relhasindex = false,   if so complain.
3. Build the index.
4. Update pg_class tuple, being prepared for concurrent   updates (ie, do NOT use simple_heap_update here).

I still don't see any value in LockClassinfoForUpdate, however.
        regards, tom lane


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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: pgindent run
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: storing binary data