Fix mishandling of background worker PGPROCs in EXEC_BACKEND builds.
authorRobert Haas
Wed, 30 Jul 2014 15:25:58 +0000 (11:25 -0400)
committerRobert Haas
Wed, 30 Jul 2014 16:10:20 +0000 (12:10 -0400)
InitProcess() relies on IsBackgroundWorker to decide whether the PGPROC
for a new backend should be taken from ProcGlobal's freeProcs or from
bgworkerFreeProcs.  In EXEC_BACKEND builds, InitProcess() is called
sooner than in non-EXEC_BACKEND builds, and IsBackgroundWorker wasn't
getting initialized soon enough.

Report by Noah Misch.  Diagnosis and fix by me.

src/backend/postmaster/postmaster.c

index 7d587ef652ebfe73a0eb1befb1ac98b10213bf61..a4aefe401e41c52158b43b88396ea38c401af65a 100644 (file)
@@ -4566,6 +4566,9 @@ SubPostmasterMain(int argc, char *argv[])
    {
        int         cookie;
 
+       /* do this as early as possible; in particular, before InitProcess() */
+       IsBackgroundWorker = true;
+
        /* Close the postmaster's sockets */
        ClosePostmasterPorts(false);