On 3 July 2014 06:45, Amit Khandekar <amit.khandekar@enterprisedb.com> wrote:
> In GetBufferWithoutRelcache(), I was wondering, rather than calling
> PinBuffer(), if we do this :
> LockBufHdr(buf);
> PinBuffer_Locked(buf);
> valid = ((buf->flags & BM_VALID) != 0);
> then we can avoid having the new buffer access strategy BAS_DISCARD that is
> introduced in this patch. And so the code changes in freelist.c would not be
> necessary.
That looks like a good idea, thanks.
I think we should say this though
LockBufHdr(buf);
valid = ((buf->flags & BM_VALID) != 0);
if (valid) PinBuffer_Locked(buf);
else UnlockBufHdr(buf);
since otherwise we would access the buffer flags without the spinlock
and we would leak a pin if the buffer was not valid
-- Simon Riggs http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services