[PATCH] Expose checkpoint reason to completion log messages.

From: Soumya S Murali <soumyamurali(dot)work(at)gmail(dot)com>
To: Michael Banck <mbanck(at)gmx(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Álvaro Herrera <alvherre(at)kurilemu(dot)de>, melanieplageman(at)gmail(dot)com, juanjo(dot)santamaria(at)gmail(dot)com
Subject: [PATCH] Expose checkpoint reason to completion log messages.
Date: 2025-12-01 11:18:56
Message-ID: CAMtXxw9tPwV=NBv5S9GZXMSKPeKv5f9hRhSjZ8__oLsoS5jcuA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

This patch is an update after reworking the “checkpoint reason” changes as
a standalone patch, separate from the pg_stat_checkpointer additions as
suggested [1]. I applied the patch on a clean tree and verified that the
logging changes work as expected under different workloads. I am attaching
the observations and patch in support for this.This would improve clarity
for performance debugging and help understand checkpoint behavior without
parsing WAL logs manually. Below is one representative checkpoint log entry
after a pgbench run and an explicit CHECKPOINT:

2025-12-01 15:33:30.121 IST [69178] LOG: checkpoint complete (immediate):
wrote 3417 buffers (20.9%), wrote 3 SLRU buffers; 0 WAL file(s) added, 0
removed, 1 recycled; write=0.122 s, sync=0.022 s, total=0.166 s; sync
files=9, longest=0.005 s, average=0.003 s; distance=31304 kB,
estimate=489729 kB; lsn=0/65E92BC8, redo lsn=0/65E92B70

Regarding the pg_stat_checkpointer extensions [1], I understand the
concerns that were raised and I will follow up with a separate full patch
once I incorporate the remaining feedback.
Thank you for the guidance. It has been very helpful. Looking forward to
more further feedback.

Regards,
Soumya

Reference
[1]
https://www.postgresql.org/message-id/flat/CAMtXxw_W6w2Q1QsCvMPnoq3xCMKzH28Zjk_EmL60oP%2BsCTkXOw%40mail.gmail.com

Attachment Content-Type Size
0001-Expose-checkpoint-reason-to-completion-log-messages.patch text/x-patch 3.4 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Mihail Nikalayeu 2025-12-01 11:27:46 Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY
Previous Message Dilip Kumar 2025-12-01 10:52:17 Re: Proposal: Conflict log history table for Logical Replication