Re: Avoiding unnecessary reads in recovery - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Avoiding unnecessary reads in recovery
Date
Msg-id 23167.1178148387@sss.pgh.pa.us
Whole thread Raw
In response to Re: Avoiding unnecessary reads in recovery  (Heikki Linnakangas <heikki@enterprisedb.com>)
List 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 by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Sequential scans
Next
From: Jeff Davis
Date:
Subject: Re: Sequential scans