On Mon, Apr 8, 2024 at 11:53 AM Melanie Plageman
<melanieplageman@gmail.com> wrote:
> I've reviewed v6. I think you should mention in the docs that it only
> works for shared buffers -- so specifically not buffers containing
> blocks of temp tables.
Thanks for looking! The whole pg_buffercache extension is for working
with shared buffers only, as mentioned at the top. I have tried to
improve that paragraph though, as it only mentioned examining them.
> In the function pg_buffercache_invalidate(), why not use the
> BufferIsValid() function?
>
> - if (buf < 1 || buf > NBuffers)
> + if (!BufferIsValid(buf) || buf > NBuffers)
It doesn't check the range (it has assertions, not errors).
> I thought the below would be more clear for the comment above
> InvalidateUnpinnedBuffer().
>
> - * Returns true if the buffer was valid and it has now been made invalid.
> - * Returns false if the wasn't valid, or it couldn't be evicted due to a pin,
> - * or if the buffer becomes dirty again while we're trying to write it out.
> + * Returns true if the buffer was valid and has now been made invalid. Returns
> + * false if it wasn't valid, if it couldn't be evicted due to a pin, or if the
> + * buffer becomes dirty again while we're trying to write it out.
Fixed.
> Some of that probably applies for the docs too (i.e. you have some
> similar wording in the docs). There is actually one typo in your
> version, so even if you don't adopt my suggestion, you should fix that
> typo.
Yeah, thanks, improved similarly there.
> I didn't notice anything else out of place. I tried it and it worked
> as expected. I'm excited to have this feature!
Thanks!
> I didn't read through this whole thread, but was there any talk of
> adding other functions to let me invalidate a bunch of buffers at once
> or even some options -- like invalidate every 3rd buffer or whatever?
> (Not the concern of this patch, but just wondering because that would
> be a useful future enhancement IMO).
TBH I tried to resist people steering in that direction because you
can also just define a SQL function to do that built on this, and if
you had specialised functions they'd never be quite right. IMHO we
succeeded in minimising the engineering and maximising flexibility,
'cause it's for hackers. Crude, but already able to express a wide
range of stuff by punting the problem to SQL.
Thanks to Palak for the patch. Pushed.