Hi,

The way we currently start and initialize individual postgres (sub-)
processes is pretty complicated and duplicative.  I've a couple
complaints:

1) It's completely non-obvious that bootstrap.c:AuxiliaryProcessMain()
   can get invoked both via postmaster for subprocesses (startup, wal
   writer, bgwriter, checkpointer, wal receiver, "checker"), as well as
   directly via main.c for the bootstrap processes.  Note the autovacuum
   launcher, archiver, logger are *not* started this way.

2) Most of the processes mentioned in 1) and some additional ones
   (autovac launcher and walsender / autovacuum workers to some degree)
   duplicate a lot of logic for startup, error handling and main loop.
   Especially the error handling code is order dependent, complex, and
   has been broken in various subprocesses in the past.

3) There exists yet *another* way of starting processes in the form of
   background workers.  Initially that was "just" for extensions, but is
   now employed for builtin tasks too, like the logical rep launcher /
   workers.  In the course of that special case handling had to be
   sprinkled around, because the bgworker logic isn't quite able to be
   good enough for something builtin.

4) The naming of initialization functions is, uh, not particularly
   clear. How many people can differentiate, without checking,
   BaseInit(), BackendInitialize(), InitPostgres(), InitProcess().

I think the complexity here just grew incrementally with the addition of
more and more subprocesses, without sufficient refactoring. I did some
in 31c453165b5a6, but that's not even remotely enough.

I think we should seriously consider doing a larger refactoring of this
soon.  I've some ideas about what to do, but I'd welcome some thoughts
on whether others consider this a serious problem or not, and what they
think we should do about this, first.

Greetings,

Andres Freund


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to