public inbox for [email protected]
help / color / mirror / Atom feedFrom: Fujii Masao <[email protected]>
To: Thom Brown <[email protected]>
Cc: Heikki Linnakangas <[email protected]>
Cc: [email protected]
Subject: Re: pgsql: Refactor how some aux processes advertise their ProcNumber
Date: Thu, 9 Jul 2026 09:57:27 +0900
Message-ID: <CAHGQGwH8n4BMjBJcL1ob6YTJYn1kTmVwO6mEYoEGyrGyNXaaXw@mail.gmail.com> (raw)
In-Reply-To: <CAA-aLv6UHXubNxmAjNH8PnyKKkaXePO1ggB15=iidNW08T4hSg@mail.gmail.com>
References: <[email protected]>
<CAA-aLv6UHXubNxmAjNH8PnyKKkaXePO1ggB15=iidNW08T4hSg@mail.gmail.com>
On Thu, Jul 9, 2026 at 6:57 AM Thom Brown <[email protected]> wrote:
> @@ -724,6 +725,14 @@ InitAuxiliaryProcess(void)
> */
> PGSemaphoreReset(MyProc->sem);
>
> + /* Some aux processes are also advertised in ProcGlobal */
> + if (MyBackendType == B_AUTOVAC_LAUNCHER)
> + pg_atomic_write_u32(&ProcGlobal->avLauncherProc, MyProcNumber);
>
> I'm looking for the places this gets called from. I can only see
> auxprocess.c which the launcher doesn't go through. The same question
> for similar code in AuxiliaryProcKill().
You're right. The autovacuum launcher does not go through
AuxiliaryProcessMainCommon(), so it never calls
InitAuxiliaryProcess(). Instead, it initializes its PGPROC with
InitProcess().
As a result, the avLauncherProc assignment added to
InitAuxiliaryProcess() is never executed for the launcher, and the
corresponding cleanup in AuxiliaryProcKill() is never reached either.
It seems we should move the avLauncherProc set/clear operations to
InitProcess()/ProcKill() path, as in the attached patch.
Regards,
--
Fujii Masao
Attachments:
[application/octet-stream] v1-0001-Advertise-autovacuum-launcher-s-ProcNumber-from-I.patch (2.0K, ../CAHGQGwH8n4BMjBJcL1ob6YTJYn1kTmVwO6mEYoEGyrGyNXaaXw@mail.gmail.com/2-v1-0001-Advertise-autovacuum-launcher-s-ProcNumber-from-I.patch)
download | inline diff:
From 86d84b81e53497cdda9722cb223df53970491714 Mon Sep 17 00:00:00 2001
From: Fujii Masao <[email protected]>
Date: Thu, 9 Jul 2026 09:23:46 +0900
Subject: [PATCH v1] Advertise autovacuum launcher's ProcNumber from
InitProcess
---
src/backend/storage/lmgr/proc.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 59640bb4f97..ce4425b5568 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -550,6 +550,9 @@ InitProcess(void)
*/
PGSemaphoreReset(MyProc->sem);
+ if (MyBackendType == B_AUTOVAC_LAUNCHER)
+ pg_atomic_write_u32(&ProcGlobal->avLauncherProc, MyProcNumber);
+
/*
* Arrange to clean up at backend exit.
*/
@@ -726,8 +729,6 @@ InitAuxiliaryProcess(void)
PGSemaphoreReset(MyProc->sem);
/* Some aux processes are also advertised in ProcGlobal */
- if (MyBackendType == B_AUTOVAC_LAUNCHER)
- pg_atomic_write_u32(&ProcGlobal->avLauncherProc, MyProcNumber);
if (MyBackendType == B_WAL_WRITER)
pg_atomic_write_u32(&ProcGlobal->walwriterProc, MyProcNumber);
if (MyBackendType == B_CHECKPOINTER)
@@ -989,6 +990,12 @@ ProcKill(int code, Datum arg)
SwitchBackToLocalLatch();
DisownLatch(&MyProc->procLatch);
+ if (MyBackendType == B_AUTOVAC_LAUNCHER)
+ {
+ Assert(pg_atomic_read_u32(&ProcGlobal->avLauncherProc) == MyProcNumber);
+ pg_atomic_write_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER);
+ }
+
proc = MyProc;
procgloballist = proc->procgloballist;
@@ -1113,11 +1120,6 @@ AuxiliaryProcKill(int code, Datum arg)
/*
* If this was one of the aux processes advertised in ProcGlobal, clear it
*/
- if (MyBackendType == B_AUTOVAC_LAUNCHER)
- {
- Assert(pg_atomic_read_u32(&ProcGlobal->avLauncherProc) == MyProcNumber);
- pg_atomic_write_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER);
- }
if (MyBackendType == B_WAL_WRITER)
{
Assert(pg_atomic_read_u32(&ProcGlobal->walwriterProc) == MyProcNumber);
--
2.55.0
view thread (8+ messages) latest in thread
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: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: pgsql: Refactor how some aux processes advertise their ProcNumber
In-Reply-To: <CAHGQGwH8n4BMjBJcL1ob6YTJYn1kTmVwO6mEYoEGyrGyNXaaXw@mail.gmail.com>
* 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