Re: Avoiding unnecessary reads in recovery

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Avoiding unnecessary reads in recovery
Дата
Msg-id 23167.1178148387@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Avoiding unnecessary reads in recovery  (Heikki Linnakangas <heikki@enterprisedb.com>)
Список pgsql-hackers
Heikki Linnakangas <heikki@enterprisedb.com> writes:
> What we could have is the semantics of "Return a buffer, with either 
> correct contents or completely zeroed out". It would act just like 
> ReadBuffer if the buffer was already in memory, and zero out the page 
> otherwise. That's a bit strange semantics to have, but is simple to 
> implement and works for the use-cases we've been talking about.

> Patch implementing that attached. I named the function "ReadOrZeroBuffer".

Applied.  BTW, I realized that there is a potential issue created by
this, which is that the smgr level might see a write for a page that it
never saw a read for.  I don't think there are any bad consequences of
this ATM, but it is skating around the edges of some bugs we've had
previously with relation extension.  In particular ReadOrZeroBuffer
avoids the error that would normally occur if one tries to read a page
that's beyond the logical EOF; and if the page is subsequently modified
and written, md.c is likely to get confused/unhappy, particularly if the
page is beyond the next segment boundary.  This isn't a problem in
XLogReadBuffer's usage because it carefully checks the EOF position
before trying to use ReadOrZeroBuffer, but it's a limitation other
callers will need to think about.
        regards, tom lane


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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Sequential scans
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: Sequential scans