Re: log_checkpoints: count WAL segment creations from all processes

From: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: log_checkpoints: count WAL segment creations from all processes
Date: 2026-03-25 01:11:41
Message-ID: CABPTF7XR3sLcGtvvrNAK8umoUYEVbdBYedNtg=ufRgT=V68ZqA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Japin,

Thanks for looking into this.

On Tue, Mar 24, 2026 at 10:01 PM Japin Li <japinli(at)hotmail(dot)com> wrote:
>
>
> Hi, Xuneng
>
> On Tue, 24 Mar 2026 at 19:17, Xuneng Zhou <xunengzhou(at)gmail(dot)com> wrote:
> > Hi Zsolt,
> >
> > On Tue, Mar 24, 2026 at 1:55 PM Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote:
> >
> > Hello!
> >
> > This is a simple patch, but shouldn't it include at least some basic
> > tests verifying the new behavior?
> >
> > Thanks for looking into this. I've added a test for it. Please take a look.
>
> Thanks for updating the patch. A few comments on v2:
>
> 1.
> + (The probes listed next fire in sequence during checkpoint processing.)
> + arg0 is the number of buffers written. arg1 is the total number of
>
> These changes seem unnecessary. Additionally, there appears to be an
> indentation issue.

Yeah, I've removed these and fixed the indentation issue.

> 2.
> + current = pg_atomic_read_u64(&XLogCtl->walSegmentsCreated);
> + CheckpointStats.ckpt_segs_added = (int)
> + (current - XLogCtl->walSegsCreatedLastCheckpoint);
> + XLogCtl->walSegsCreatedLastCheckpoint = current;
>
> Is integer overflow a concern here? It seems unlikely in practice.

I don’t think overflow is a concern here, but it might still be
helpful to add some comments to mention it.

> >
> > --
> > Best,
> > Xuneng
> >
> > [4. text/x-diff; v2-0001-Count-WAL-segment-creations-by-all-processes-in-l.patch]...
>

--
Best,
Xuneng

Attachment Content-Type Size
v3-0001-Count-WAL-segment-creations-by-all-processes-in-l.patch application/octet-stream 11.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Jackson 2026-03-25 01:13:24 Add http connection service file functionality
Previous Message Fujii Masao 2026-03-25 00:51:17 Re: Use SIGTERM instead of SIGUSR1 for slotsync worker to exit during promotion?