Re: Odd off-by-one dirty buffers and checkpoint buffers written - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Odd off-by-one dirty buffers and checkpoint buffers written
Date
Msg-id CAKFQuwYQub49cNg_vpfJew3QS0Jgji2tx=AE8=_nx83XkzQs+w@mail.gmail.com
Whole thread Raw
In response to Re: Odd off-by-one dirty buffers and checkpoint buffers written  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: Odd off-by-one dirty buffers and checkpoint buffers written
List pgsql-hackers
On Tue, Apr 19, 2022 at 4:36 PM Nathan Bossart <nathandbossart@gmail.com> wrote:
On Tue, Apr 19, 2022 at 04:21:21PM -0700, David G. Johnston wrote:
> I've done this four times in a row and while the number of dirty buffers
> shown each time vary (see below) I see that "wrote N buffers" is always
> exactly one more than the total count of dirty buffers.  I'm just curious
> if anyone has a quick answer for this unusual correspondence.

I see that SlruInternalWritePage() increments ckpt_bufs_written, so my
first guess would be that it's due to something like CheckPointCLOG().


I peeked at pg_stat_bgwriter and see an increase in buffers_checkpoint matching the dirty buffers number.

I also looked at pg_stat_slru to try and find the corresponding change caused by:

slru.c:766 (SlruPhysicalWritePage)
pgstat_count_slru_page_written(shared->slru_stats_idx);

I do see (Xact) blks_hit change during this process (after the update/commit, not the checkpoint, though) but it increases by 2 when dirty buffers is 4.  I was expecting 4, thinking that blocks and buffers and pages are basically the same things (which [1] seems to affirm).


David J.

pgsql-hackers by date:

Previous
From: Japin Li
Date:
Subject: Re: Replace open mode with PG_BINARY_R/W/A macros
Next
From: Martín Marqués
Date:
Subject: Re: Postgres restart in the middle of exclusive backup and the presence of backup_label file