Fix comments about bgworker registration before MaxBackends initialization
authorMichael Paquier <michael@paquier.xyz>
Sat, 29 Jan 2022 01:47:36 +0000 (10:47 +0900)
committerMichael Paquier <michael@paquier.xyz>
Sat, 29 Jan 2022 01:47:36 +0000 (10:47 +0900)
Since 6bc8ef0b, InitializeMaxBackends() has used max_worker_processes
instead of adapting MaxBackends to the number of background workers
registered by modules loaded in shared_preload_libraries (at this time,
bgworkers were only static, but gained dynamic capabilities as a matter
of supporting parallel queries meaning that a control cap was
necessary).

Some comments referred to the past registration logic, making them
confusing and incorrect, so fix these.

Some of the out-of-core modules that could be loaded in this path
sometimes like to manipulate dynamically some of the resource-related
GUCs for their own needs, this commit adds a note about that.

Author: Nathan Bossart
Discussion: https://postgr.es/m/20220127181815.GA551692@nathanxps13

src/backend/postmaster/postmaster.c
src/backend/utils/init/postinit.c

index dc4afdd75ae7db8088e0a6927f1cffc95725050e..ac0ec0986a223e657da702a3f02b387e4c1a17a2 100644 (file)
@@ -1014,10 +1014,8 @@ PostmasterMain(int argc, char *argv[])
        LocalProcessControlFile(false);
 
        /*
-        * Register the apply launcher.  Since it registers a background worker,
-        * it needs to be called before InitializeMaxBackends(), and it's probably
-        * a good idea to call it before any modules had chance to take the
-        * background worker slots.
+        * Register the apply launcher.  It's probably a good idea to call this
+        * before any modules had a chance to take the background worker slots.
         */
        ApplyLauncherRegister();
 
@@ -1038,8 +1036,8 @@ PostmasterMain(int argc, char *argv[])
 #endif
 
        /*
-        * Now that loadable modules have had their chance to register background
-        * workers, calculate MaxBackends.
+        * Now that loadable modules have had their chance to alter any GUCs,
+        * calculate MaxBackends.
         */
        InitializeMaxBackends();
 
index d046caabd7d8b3dd07a623bca74768cff4bba112..cd7c829ff5d37587223bae58b5427e5332e6bc08 100644 (file)
@@ -483,9 +483,8 @@ pg_split_opts(char **argv, int *argcp, const char *optstr)
 /*
  * Initialize MaxBackends value from config options.
  *
- * This must be called after modules have had the chance to register background
- * workers in shared_preload_libraries, and before shared memory size is
- * determined.
+ * This must be called after modules have had the chance to alter GUCs in
+ * shared_preload_libraries and before shared memory size is determined.
  *
  * Note that in EXEC_BACKEND environment, the value is passed down from
  * postmaster to subprocesses via BackendParameters in SubPostmasterMain; only