From: Nathan Bossart <nathandbossart@gmail.com>
To: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Refactor how some aux processes advertise their ProcNumber
Date: Wed, 8 Jul 2026 22:10:55 -0500
Message-ID: <ak8RP8xn5_H0BrJV@nathan> (raw)
In-Reply-To: <E1whWIW-000ArK-1q@gemulon.postgresql.org>
References: <E1whWIW-000ArK-1q@gemulon.postgresql.org>
On Wed, Jul 08, 2026 at 05:43:01PM +0000, Heikki Linnakangas wrote:
> Switch to pg_atomic_uint32 for the fields. Seems easier to reason
> about than volatile pointers. There was some precedence for that, as
> were already using pg_atomic_uint32 for the procArrayGroupFirst and
> clogGroupFirst fields, which also store ProcNumbers.
Since removing volatile qualifiers is on my mind, I noticed that this patch
makes it possible to remove two more. Patch attached.
--
nathan
Attachments:remove_more_volatile.patch (text/plain, 1.0K) downloaddiff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.cindex a09d4097d51..f6351f1eb10 100644--- a/src/backend/postmaster/checkpointer.c+++ b/src/backend/postmaster/checkpointer.c@@ -1114,8 +1114,7 @@ RequestCheckpoint(int flags)
#define MAX_SIGNAL_TRIES 600 /* max wait 60.0 sec */
for (ntries = 0;; ntries++)
{
- volatile PROC_HDR *procglobal = ProcGlobal;- ProcNumber checkpointerProc = pg_atomic_read_u32(&procglobal->checkpointerProc);+ ProcNumber checkpointerProc = pg_atomic_read_u32(&ProcGlobal->checkpointerProc);
if (checkpointerProc == INVALID_PROC_NUMBER)
{
@@ -1536,8 +1535,7 @@ FirstCallSinceLastCheckpoint(void)
void
WakeupCheckpointer(void)
{
- volatile PROC_HDR *procglobal = ProcGlobal;- ProcNumber checkpointerProc = pg_atomic_read_u32(&procglobal->checkpointerProc);+ ProcNumber checkpointerProc = pg_atomic_read_u32(&ProcGlobal->checkpointerProc);
if (checkpointerProc != INVALID_PROC_NUMBER)
SetLatch(&GetPGProcByNumber(checkpointerProc)->procLatch);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: nathandbossart@gmail.com, heikki.linnakangas@iki.fi
Subject: Re: pgsql: Refactor how some aux processes advertise their ProcNumber
In-Reply-To: <ak8RP8xn5_H0BrJV@nathan>
References: <E1whWIW-000ArK-1q@gemulon.postgresql.org> <ak8RP8xn5_H0BrJV@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox