diff options
Diffstat (limited to 'src/backend/postmaster/bgworker.c')
-rw-r--r-- | src/backend/postmaster/bgworker.c | 67 |
1 files changed, 25 insertions, 42 deletions
diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c index 11c4ceddbf6..c05f5006393 100644 --- a/src/backend/postmaster/bgworker.c +++ b/src/backend/postmaster/bgworker.c @@ -652,17 +652,24 @@ static bool SanityCheckBackgroundWorker(BackgroundWorker *worker, int elevel) { /* sanity check for flags */ - if (worker->bgw_flags & BGWORKER_BACKEND_DATABASE_CONNECTION) + + /* + * We used to support workers not connected to shared memory, but don't + * anymore. Thus this is a required flag now. We're not removing the flag + * for compatibility reasons and because the flag still provides some + * signal when reading code. + */ + if (!(worker->bgw_flags & BGWORKER_SHMEM_ACCESS)) { - if (!(worker->bgw_flags & BGWORKER_SHMEM_ACCESS)) - { - ereport(elevel, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("background worker \"%s\": must attach to shared memory in order to request a database connection", - worker->bgw_name))); - return false; - } + ereport(elevel, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("background worker \"%s\": background worker without shared memory access are not supported", + worker->bgw_name))); + return false; + } + if (worker->bgw_flags & BGWORKER_BACKEND_DATABASE_CONNECTION) + { if (worker->bgw_start_time == BgWorkerStart_PostmasterStart) { ereport(elevel, @@ -745,20 +752,6 @@ StartBackgroundWorker(void) MyBackendType = B_BG_WORKER; init_ps_display(worker->bgw_name); - /* - * If we're not supposed to have shared memory access, then detach from - * shared memory. If we didn't request shared memory access, the - * postmaster won't force a cluster-wide restart if we exit unexpectedly, - * so we'd better make sure that we don't mess anything up that would - * require that sort of cleanup. - */ - if ((worker->bgw_flags & BGWORKER_SHMEM_ACCESS) == 0) - { - ShutdownLatchSupport(); - dsm_detach_all(); - PGSharedMemoryDetach(); - } - SetProcessingMode(InitProcessing); /* Apply PostAuthDelay */ @@ -832,29 +825,19 @@ StartBackgroundWorker(void) PG_exception_stack = &local_sigjmp_buf; /* - * If the background worker request shared memory access, set that up now; - * else, detach all shared memory segments. + * Create a per-backend PGPROC struct in shared memory, except in the + * EXEC_BACKEND case where this was done in SubPostmasterMain. We must + * do this before we can use LWLocks (and in the EXEC_BACKEND case we + * already had to do some stuff with LWLocks). */ - if (worker->bgw_flags & BGWORKER_SHMEM_ACCESS) - { - /* - * Create a per-backend PGPROC struct in shared memory, except in the - * EXEC_BACKEND case where this was done in SubPostmasterMain. We must - * do this before we can use LWLocks (and in the EXEC_BACKEND case we - * already had to do some stuff with LWLocks). - */ #ifndef EXEC_BACKEND - InitProcess(); + InitProcess(); #endif - /* - * Early initialization. Some of this could be useful even for - * background workers that aren't using shared memory, but they can - * call the individual startup routines for those subsystems if - * needed. - */ - BaseInit(); - } + /* + * Early initialization. + */ + BaseInit(); /* * Look up the entry point function, loading its library if necessary. |