Thread

  1. Re: log_checkpoints: count WAL segment creations from all processes

    Hüseyin Demir <huseyin.d3r@gmail.com> — 2026-05-16T17:22:35Z

    Hi,
    
    Thanks for the patch. The idea is good and can we introduce a new
    counter to pg_stat_checkpointer ? For example, we can add
    wal_segments_created to this view and it would be useful for capacity
    planning and load estimations.
    
    Additionally I have a few questions
    
    - Should we make walSegsCreatedLastCheckpoint atomic ? In the future
    we can also add this to views maybe. It's an auxiliary suggestion.
    - ckpt_segs_added is defined as int but overflow threshold is 2^32 in
    comments. Shouldn't we use 2^31 for int ?
    - Maybe it's a bad idea but should we extend the tests with the
    wal_level set to minimal ?
    
    PS: I created a patch to expose wal_segments_created to
    pg_stat_checkpointer view. You can review it and enhance your patch if
    you need. I created it to explain my idea better so it can be
    destroyed after your review. But I couldn't create a patch for
    preceding questions.
    
    Regards,
    Demir.
    
    
    Xuneng Zhou <xunengzhou@gmail.com>, 25 Mar 2026 Çar, 03:10 tarihinde şunu yazdı:
    >
    > On Wed, Mar 25, 2026 at 9:11 AM Xuneng Zhou <xunengzhou@gmail.com> wrote:
    > >
    > > Hi Japin,
    > >
    > > Thanks for looking into this.
    > >
    > > On Tue, Mar 24, 2026 at 10:01 PM Japin Li <japinli@hotmail.com> wrote:
    > > >
    > > >
    > > > Hi, Xuneng
    > > >
    > > > On Tue, 24 Mar 2026 at 19:17, Xuneng Zhou <xunengzhou@gmail.com> wrote:
    > > > > Hi Zsolt,
    > > > >
    > > > > On Tue, Mar 24, 2026 at 1:55 PM Zsolt Parragi <zsolt.parragi@percona.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.
    > >
    >
    > v4 fixed the inaccurate overflow numbers in comments.
    >
    > --
    > Best,
    > Xuneng
    
  2. Re: log_checkpoints: count WAL segment creations from all processes

    Hüseyin Demir <huseyin.d3r@gmail.com> — 2026-05-17T09:10:36Z

    Hi,
    
    Thanks for the patch. The idea is good and can we introduce a new
    counter to pg_stat_checkpointer ? For example, we can add
    wal_segments_created to this view and it would be useful for capacity
    planning and load estimations.
    
    Additionally I have a few questions
    
    - Should we make walSegsCreatedLastCheckpoint atomic ? In the future
    we can also add this to views maybe. It's an auxiliary suggestion.
    - ckpt_segs_added is defined as int but overflow threshold is 2^32 in
    comments. Shouldn't we use 2^31 for int ?
    - Maybe it's a bad idea but should we extend the tests with the
    wal_level set to minimal ?
    
    PS: I created a patch to expose wal_segments_created to
    pg_stat_checkpointer view. You can review it and enhance your patch if
    you need. I created it to explain my idea better so it can be
    destroyed after your review. But I couldn't create a patch for
    preceding questions.
    
    Regards,
    Demir.