Re: Summary function for pg_buffercache - Mailing list pgsql-hackers

From Zhang Mingli
Subject Re: Summary function for pg_buffercache
Date
Msg-id 217ae4ea-b08a-4256-9cea-9447d686d7d9@Spark
Whole thread Raw
In response to Re: Summary function for pg_buffercache  (Melih Mutlu <m.melihmutlu@gmail.com>)
List pgsql-hackers
Hi,
On Sep 20, 2022, 20:49 +0800, Melih Mutlu <m.melihmutlu@gmail.com>, wrote:
Hi Zhang,

Those are two different locks.
The locks that are taken in the patch are for buffer headers. This locks only the current buffer and makes that particular buffer's info consistent within itself.

However, the lock mentioned in the doc is for buffer manager which would prevent changes on any buffer if it's held. 
pg_buffercache_summary (and pg_buffercache_pages) does not hold buffer manager lock. Therefore, consistency across all buffers is not guaranteed.

For pg_buffercache_pages, self-consistent buffer information is useful since it shows each buffer separately.

For pg_buffercache_summary, even self-consistency may not matter much since results are aggregated and we can't see individual buffer information.
Consistency across all buffers is also not a concern since its purpose is to give an overall idea about the state of buffers.

I see that these two different locks in the same context can be confusing. I hope it is a bit more clear now.

Best,
Melih
Thanks for your explanation, LGTM.

pgsql-hackers by date:

Previous
From: Melih Mutlu
Date:
Subject: Re: Summary function for pg_buffercache
Next
From: Robert Haas
Date:
Subject: Re: HOT chain validation in verify_heapam()