Re: ReadRecentBuffer() is broken for local buffer

Поиск
Список
Период
Сортировка
От Richard Guo
Тема Re: ReadRecentBuffer() is broken for local buffer
Дата
Msg-id CAMbWs4-m8LpiPfMxRk4ALLaHN7zPCB5hNLa4h1yreZWk6OKKfw@mail.gmail.com
обсуждение исходный текст
Ответ на ReadRecentBuffer() is broken for local buffer  (Heikki Linnakangas <hlinnaka@iki.fi>)
Список pgsql-hackers

On Mon, Jul 25, 2022 at 2:22 AM Heikki Linnakangas <hlinnaka@iki.fi> wrote:
        if (BufferIsLocal(recent_buffer))
        {
-               bufHdr = GetBufferDescriptor(-recent_buffer - 1);
+               bufHdr = GetLocalBufferDescriptor(-recent_buffer - 1);

Aha, we're using the wrong buffer descriptors here. Currently this
function is only called in XLogReadBufferExtended(), so the branch for
local buffer cannot be reached. Maybe that's why it is not identified
until now. 
 
The code after that looks suspicious, too. It increases the usage count
even if the buffer was already pinned. That's different from what it
does for a shared buffer, and different from LocalBufferAlloc(). That's
pretty harmless, just causes the usage count to be bumped more
frequently, but I don't think it was intentional. The ordering of
bumping the usage count, the local ref count, and registration in the
resource owner are different too. As far as I can see, that makes no
difference, but I think we should keep this code as close as possible to
similar code used elsewhere, unless there's a particular reason to differ.

Agree. Maybe we can wrap the codes in an inline function or macro and
call that in both LocalBufferAlloc and here.

Thanks
Richard

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Unprivileged user can induce crash by using an SUSET param in PGOPTIONS
Следующее
От: Nathan Bossart
Дата:
Сообщение: Re: optimize lookups in snapshot [sub]xip arrays