On Mon, Feb 25, 2019 at 1:41 PM Mike Palmiotto <mike.palmio...@crunchydata.com> wrote: > > <snip> > > > > If memory serves, StartChildProcess already was an attempt to unify > > the treatment of postmaster children. It's possible that another > > round of unification would be productive, but I think you'll find > > that there are random small differences in requirements that'd > > make it messy. > > It kind of seemed like it, but I noticed the small differences in > requirements, which made me a bit hesitant. I'll go ahead and see what > I can do and submit the patch for consideration.
I'm considering changing StartChildProcess to take a struct with data for forking/execing each different process. Each different backend type would build up the struct and then pass it on to StartChildProcess, which would handle each separately. This would ensure that the fork type is set prior to InitPostmasterChild and would provide us with the information necessary to do what we need in the InitPostmasterChild_hook. Attached is a patch to fork_process.h which shows roughly what I'm thinking. Does this seem somewhat sane as a first step? -- Mike Palmiotto Software Engineer Crunchy Data Solutions https://crunchydata.com
diff --git a/src/include/postmaster/fork_process.h b/src/include/postmaster/fork_process.h index eb3c8ec974..6cf0bfa2fe 100644 --- a/src/include/postmaster/fork_process.h +++ b/src/include/postmaster/fork_process.h @@ -12,6 +12,29 @@ #ifndef FORK_PROCESS_H #define FORK_PROCESS_H +typedef enum +{ + CheckerProcess = 0, + BootstrapProcess, + StartupProcess, + BgWriterProcess, + CheckpointerProcess, + WalWriterProcess, + WalReceiverProcess, + AutoVacuumLauncherProcess, + AutoVacuumWorkerProcess, + SysloggerProcess, + BgWorkerProcess + + NUMFORKPROCTYPES /* Must be last! */ +} ForkProcType; + +typedef struct ForkProcData +{ + ForkProcType type; + char *fork_av[10]; +} ForkProcData + extern pid_t fork_process(void); #endif /* FORK_PROCESS_H */