From aeebacff114634ffa07b5299ee6c41b219717bc3 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Wed, 30 Jul 2014 11:25:58 -0400 Subject: [PATCH] Fix mishandling of background worker PGPROCs in EXEC_BACKEND builds. 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 9548caa0ae..39fa564191 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -4672,6 +4672,9 @@ SubPostmasterMain(int argc, char *argv[]) { int shmem_slot; + /* do this as early as possible; in particular, before InitProcess() */ + IsBackgroundWorker = true; + /* Close the postmaster's sockets */ ClosePostmasterPorts(false);