Re: [PATCH] introduce XLogLockBlockRangeForCleanup() - Mailing list pgsql-hackers

From Simon Riggs
Subject Re: [PATCH] introduce XLogLockBlockRangeForCleanup()
Date
Msg-id CA+U5nMLSHYFkwTaHFg+jO3gvOL3aUOkEeWZUwXBOhgM-KBEyyQ@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] introduce XLogLockBlockRangeForCleanup()  (Amit Khandekar <amit.khandekar@enterprisedb.com>)
Responses Re: [PATCH] introduce XLogLockBlockRangeForCleanup()
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Abhijit Menon-Sen
Date:
Subject: Re: [PATCH] introduce XLogLockBlockRangeForCleanup()
Next
From: Fujii Masao
Date:
Subject: Re: gaussian distribution pgbench