Re: Multiple FPI_FOR_HINT for the same block during killing btreeindex items

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Multiple FPI_FOR_HINT for the same block during killing btreeindex items
Дата
Msg-id 20200515215257.GA28206@alvherre.pgsql
обсуждение исходный текст
Ответ на Re: Multiple FPI_FOR_HINT for the same block during killing btreeindex items  (Masahiko Sawada <masahiko.sawada@2ndquadrant.com>)
Ответы Re: Multiple FPI_FOR_HINT for the same block during killing btreeindex items  (Ranier Vilela <ranier.vf@gmail.com>)
Re: Multiple FPI_FOR_HINT for the same block during killing btreeindex items  (Ranier Vilela <ranier.vf@gmail.com>)
Список pgsql-hackers
On 2020-Apr-10, Masahiko Sawada wrote:

> Okay. I think only adding the check would also help with reducing the
> likelihood. How about the changes for the current HEAD I've attached?

Pushed this to all branches.  (Branches 12 and older obviously needed an
adjustment.)  Thanks!

> Related to this behavior on btree indexes, this can happen even on
> heaps during searching heap tuples. To reduce the likelihood of that
> more generally I wonder if we can acquire a lock on buffer descriptor
> right before XLogSaveBufferForHint() and set a flag to the buffer
> descriptor that indicates that we're about to log FPI for hint bit so
> that concurrent process can be aware of that.

I'm not sure how that helps; the other process would have to go back and
redo their whole operation from scratch in order to find out whether
there's still something alive that needs killing.

I think you need to acquire the exclusive lock sooner: if, when scanning
the page, you find a killable item, *then* upgrade the lock to exclusive
and restart the scan.  This means that we'll have to wait for any other
process that's doing the scan, and they will all give up their share
lock to wait for the exclusive lock they need.  So the one that gets it
first will do all the killing, log the page, then release the lock.  At
that point the other processes will wake up and see that items have been
killed, so they will return having done nothing.

Like the attached.  I didn't verify that it works well or that it
actually improves performance ...

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Вложения

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

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: Re: Potentially misleading name of libpq pass phrase hook
Следующее
От: Thomas Munro
Дата:
Сообщение: Re: pgindent && weirdness