Re: buffercache/bgwriter - Mailing list pgsql-performance

From Jeff Janes
Subject Re: buffercache/bgwriter
Date
Msg-id AANLkTimA4-s1hntzZp5bXbCMGhOru4qk+Ft1WXGt_-Rs@mail.gmail.com
Whole thread Raw
In response to Re: buffercache/bgwriter  (Uwe Bartels <uwe.bartels@gmail.com>)
List pgsql-performance
On Wed, Mar 23, 2011 at 8:26 AM, Uwe Bartels <uwe.bartels@gmail.com> wrote:
> Hi Brad,
>
> yes. that's the question....
> in the source code in freelist.c there is something that I don't understand.
>
> This is the first try to get a free page. The second try scans used buffers.
> What makes me wonder is the why postgres is checking for <<buf->usage_count
> == 0>>
> where usage_count is supposed to be NULL initially.

The code comment preceding that check seems to explain that it is
probably not needed but simply done from an abundance of caution.

>         /*
>          * If the buffer is pinned or has a nonzero usage_count, we cannot
> use
>          * it; discard it and retry.  (This can only happen if VACUUM put a
>          * valid buffer in the freelist and then someone else used it before
>          * we got to it.  It's probably impossible altogether as of 8.3, but
>          * we'd better check anyway.)

Seems like maybe an Assert would be called for.

Cheers,

Jeff

pgsql-performance by date:

Previous
From: Uwe Bartels
Date:
Subject: Re: buffercache/bgwriter
Next
From: Josh Berkus
Date:
Subject: Shouldn't we have a way to avoid "risky" plans?