agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: 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
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index 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);
Attachments:
[text/plain] remove_more_volatile.patch (1.0K, ../ak8RP8xn5_H0BrJV@nathan/2-remove_more_volatile.patch)
download | inline diff:
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index 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);
view thread (8+ messages) latest in thread
Message-ID: <ak8RP8xn5_H0BrJV@nathan>
Permalink: ../ak8RP8xn5_H0BrJV@nathan/
Also on: postgresql.org/message-id/ak8RP8xn5_H0BrJV@nathan
reply
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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: nathandbossart@gmail.com, heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Refactor how some aux processes advertise their ProcNumber
In-Reply-To: <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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox