Protect some initializations from being called during backend startup.

On EXEC_BACKEND builds these functions shouldn't be called at every
backend start.
pull/1816/head
Andres Freund 2017-11-06 09:49:32 -08:00 committed by Brian Cloutier
parent d267e0f9fa
commit d063658d6d
4 changed files with 22 additions and 6 deletions

View File

@ -170,8 +170,13 @@ _PG_init(void)
/*
* Extend the database directory structure before continuing with
* initialization - one of the later steps might require them to exist.
* If in a sub-process (windows / EXEC_BACKEND) this already has been
* done.
*/
CreateRequiredDirectories();
if (!IsUnderPostmaster)
{
CreateRequiredDirectories();
}
/*
* Register Citus configuration variables. Do so before intercepting

View File

@ -297,7 +297,10 @@ void
InitializeBackendManagement(void)
{
/* allocate shared memory */
RequestAddinShmemSpace(BackendManagementShmemSize());
if (!IsUnderPostmaster)
{
RequestAddinShmemSpace(BackendManagementShmemSize());
}
prev_shmem_startup_hook = shmem_startup_hook;
shmem_startup_hook = BackendManagementShmemInit;

View File

@ -107,7 +107,10 @@ static bool LockCitusExtension(void);
void
InitializeMaintenanceDaemon(void)
{
RequestAddinShmemSpace(MaintenanceDaemonShmemSize());
if (!IsUnderPostmaster)
{
RequestAddinShmemSpace(MaintenanceDaemonShmemSize());
}
prev_shmem_startup_hook = shmem_startup_hook;
shmem_startup_hook = MaintenanceDaemonShmemInit;

View File

@ -100,12 +100,17 @@ TaskTrackerRegister(void)
{
BackgroundWorker worker;
/* organize and register initialization of required shared memory */
RequestAddinShmemSpace(TaskTrackerShmemSize());
prev_shmem_startup_hook = shmem_startup_hook;
shmem_startup_hook = TaskTrackerShmemInit;
if (IsUnderPostmaster)
{
return;
}
/* organize and register initialization of required shared memory */
RequestAddinShmemSpace(TaskTrackerShmemSize());
/* and that the task tracker is started as background worker */
memset(&worker, 0, sizeof(worker));
worker.bgw_flags = BGWORKER_SHMEM_ACCESS;