| From: | Soumya S Murali <soumyamurali(dot)work(at)gmail(dot)com> |
|---|---|
| To: | Michael Banck <mbanck(at)gmx(dot)net> |
| Cc: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, VASUKI M <vasukianand0119(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, melanieplageman(at)gmail(dot)com, juanjo(dot)santamaria(at)gmail(dot)com |
| Subject: | Re: [PATCH] Expose checkpoint reason to completion log messages. |
| Date: | 2026-01-12 07:23:54 |
| Message-ID: | CAMtXxw_o3TTaUiTqqwMCEMtLNESX9-Dvd60=CkgQO37KW1AkXQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi all,
On Thu, Jan 8, 2026 at 11:06 PM Michael Banck <mbanck(at)gmx(dot)net> wrote:
>
> Hi,
>
> On Thu, Jan 08, 2026 at 11:58:43AM +0530, Soumya S Murali wrote:
> > On Wed, Jan 7, 2026 at 1:37 PM Michael Banck <mbanck(at)gmx(dot)net> wrote:
> > > On Wed, Jan 07, 2026 at 12:35:08PM +0530, Soumya S Murali wrote:
> > I have reworked the patch to factor out the checkpoint reason logic to
> > use the same wording for both checkpoint start and completion log
> > (including wal, time, fast, force, and wait). The format has been
> > aligned with existing conventions and has been verified by running
> > make check and recovery TAP tests including t/019_replslot_limit.pl
> > successfully.
> > Kindly review my patch and let me know the feedback.
>
> Thanks for the new patch.
>
> > index 22d0a2e8c3..9f7439f9a2 100644
> > --- a/src/backend/access/transam/xlog.c
> > +++ b/src/backend/access/transam/xlog.c
> [...]
> > +static const char *
> > +CheckpointReasonString(int flags)
> > +{
> > + static char buf[128];
> > +
> > + buf[0] = '\0';
> > +
> > + if (flags & CHECKPOINT_IS_SHUTDOWN)
> > + strcat(buf, " shutdown");
> > + if (flags & CHECKPOINT_END_OF_RECOVERY)
> > + strcat(buf, " end-of-recovery");
> > + if (flags & CHECKPOINT_FAST)
> > + strcat(buf, " fast");
> > + if (flags & CHECKPOINT_FORCE)
> > + strcat(buf, " force");
> > + if (flags & CHECKPOINT_WAIT)
> > + strcat(buf, " wait");
> > + if (flags & CHECKPOINT_CAUSE_XLOG)
> > + strcat(buf, " wal");
> > + if (flags & CHECKPOINT_CAUSE_TIME)
> > + strcat(buf, " time");
> > + if (flags & CHECKPOINT_FLUSH_UNLOGGED)
> > + strcat(buf, " flush-unlogged");
> > +
> > + return buf;
> > +}
>
> The way this is coded now prepends the final string with a space
> character. This is fine for the checkpoint starting message, but makes
> the checkpoint finished message look slightly weird (not the "( wal)"):
>
> |2026-01-08 18:30:33.691 CET [1666416] LOG: checkpoint complete ( wal):
> |wrote 20 buffers (0.1%), wrote 0 SLRU buffers; 0 WAL file(s) added, 4
> |removed, 33 recycled; write=2.221 s, sync=0.019 s, total=2.701 s; sync
> |files=3, longest=0.018 s, average=0.007 s; distance=601885 kB,
> |estimate=601885 kB; lsn=0/D2D59FC8, redo lsn=0/B492B500
>
> Also I think the translators might now complain, but I am not sure how
> to best approach this.
Based on the feedback received, I have reworked and implemented a
helper function so that both checkpoint start and completion messages
use the same wording and would remain in sync, extending the same
reason reporting to restart points for completeness and better
observability, ensuring consistent terminology with existing log
output, had removed the previous use of global state and instead
passed checkpoint flags explicitly and have fixed formatting and
whitespace issues noted during review.
Also, I have tested and validated the logic successfully. I have
attached the updated patch for further review.
Kindly review the patch and let me know the feedback.
Regards,
Soumya
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Expose-checkpoint-reason-in-completion-log-messages.patch | text/x-patch | 5.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | tushar | 2026-01-12 07:35:52 | Re: Non-text mode for pg_dumpall |
| Previous Message | Peter Smith | 2026-01-12 07:09:35 | Re: Proposal: Conflict log history table for Logical Replication |