Re: Refactoring backend fork+exec code - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Refactoring backend fork+exec code
Date
Msg-id f3ecd4cb-85ee-4e54-8278-5fabfb3a4ed0@iki.fi
Whole thread Raw
In response to Re: Refactoring backend fork+exec code  (Heikki Linnakangas <hlinnaka@iki.fi>)
Responses Re: Refactoring backend fork+exec code
List 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 (https://neon.tech)

Attachment

pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: [patch] pg_basebackup: mention that spread checkpoints are the default in --help
Next
From: Magnus Hagander
Date:
Subject: Re: Postgres Partitions Limitations (5.11.2.3)