In a bootstrap process or standalone backend, set MaxBackends = 1
authorTom Lane <[email protected]>
Thu, 3 Oct 2002 19:19:09 +0000 (19:19 +0000)
committerTom Lane <[email protected]>
Thu, 3 Oct 2002 19:19:09 +0000 (19:19 +0000)
to avoid unnecessary consumption of semaphores.

src/backend/utils/init/postinit.c

index b9600805ac79abf0cba229e38bb4ec23a83ee1a0..542d662ec0e2af6005f1c59807d32de7f6ca7580 100644 (file)
@@ -172,11 +172,14 @@ InitCommunication(void)
        if (!IsUnderPostmaster)         /* postmaster already did this */
        {
                /*
-                * we're running a postgres backend by itself with no front end or
-                * postmaster.  Create private "shmem" and semaphores.  Setting
-                * MaxBackends = 16 is arbitrary.
+                * We're running a postgres bootstrap process or a standalone backend.
+                * Create private "shmem" and semaphores.  Force MaxBackends to 1 so
+                * that we don't allocate more resources than necessary.
                 */
-               CreateSharedMemoryAndSemaphores(true, 16, 0);
+               SetConfigOption("max_connections", "1",
+                                               PGC_POSTMASTER, PGC_S_OVERRIDE);
+
+               CreateSharedMemoryAndSemaphores(true, MaxBackends, 0);
        }
 }