Re: Refactoring backend fork+exec code

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Andres Freund <andres(at)anarazel(dot)de>, Tristan Partin <tristan(at)neon(dot)tech>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: Re: Refactoring backend fork+exec code
Date: 2024-01-10 12:35:52
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 08/12/2023 14:33, Heikki Linnakangas wrote:
>>> + [PMC_AV_LAUNCHER] = {"autovacuum launcher", AutoVacLauncherMain, true},
>>> + [PMC_AV_WORKER] = {"autovacuum worker", AutoVacWorkerMain, true},
>>> + [PMC_BGWORKER] = {"bgworker", BackgroundWorkerMain, true},
>>> + [PMC_SYSLOGGER] = {"syslogger", SysLoggerMain, false},
>>> +
>>> + [PMC_STARTUP] = {"startup", StartupProcessMain, true},
>>> + [PMC_BGWRITER] = {"bgwriter", BackgroundWriterMain, true},
>>> + [PMC_ARCHIVER] = {"archiver", PgArchiverMain, true},
>>> + [PMC_CHECKPOINTER] = {"checkpointer", CheckpointerMain, true},
>>> + [PMC_WAL_WRITER] = {"wal_writer", WalWriterMain, true},
>>> + [PMC_WAL_RECEIVER] = {"wal_receiver", WalReceiverMain, true},
>>> +};
>> It feels like we have too many different ways of documenting the type of a
>> process. This new PMC_ stuff, enum AuxProcType, enum BackendType.
> Agreed. And "am_walsender" and such variables.

Here's a patch that gets rid of AuxProcType. It's independent of the
other patches in this thread; if this is committed, I'll rebase the rest
of the patches over this and get rid of the new PMC_* enum.

Three patches, actually. The first one fixes an existing comment that I
noticed to be incorrect while working on this. I'll push that soon,
barring objections. The second one gets rid of AuxProcType, and the
third one replaces IsBackgroundWorker, IsAutoVacuumLauncherProcess() and
IsAutoVacuumWorkerProcess() with checks on MyBackendType. So
MyBackendType is now the primary way to check what kind of a process the
current process is.

'am_walsender' would also be fairly straightforward to remove and
replace with AmWalSenderProcess(). I didn't do that because we also have
am_db_walsender and am_cascading_walsender which cannot be directly
replaced with MyBackendType. Given that, it might be best to keep
am_walsender for symmetry.

Heikki Linnakangas
Neon (

Attachment Content-Type Size
v6-0001-Fix-incorrect-comment-on-how-BackendStatusArray-i.patch text/x-patch 1.6 KB
v6-0002-Remove-MyAuxProcType-use-MyBackendType-instead.patch text/x-patch 12.8 KB
v6-0003-Use-MyBackendType-in-more-places-to-check-what-pr.patch text/x-patch 19.4 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2024-01-10 12:41:23 Re: Postgres Partitions Limitations (
Previous Message Magnus Hagander 2024-01-10 12:33:25 Re: [patch] pg_basebackup: mention that spread checkpoints are the default in --help