diff options
Diffstat (limited to 'src/backend/storage/lmgr/proc.c')
-rw-r--r-- | src/backend/storage/lmgr/proc.c | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 0d8162a2cca..eaf3916f282 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -354,6 +354,19 @@ InitProcess(void) if (MyProc != NULL) elog(ERROR, "you already exist"); + /* + * Before we start accessing the shared memory in a serious way, mark + * ourselves as an active postmaster child; this is so that the postmaster + * can detect it if we exit without cleaning up. (XXX autovac launcher + * currently doesn't participate in this; it probably should.) + * + * Slot sync worker also does not participate in it, see comments atop + * 'struct bkend' in postmaster.c. + */ + if (IsUnderPostmaster && !AmAutoVacuumLauncherProcess() && + !AmLogicalSlotSyncWorkerProcess()) + RegisterPostmasterChildActive(); + /* Decide which list should supply our PGPROC. */ if (AmAutoVacuumLauncherProcess() || AmAutoVacuumWorkerProcess()) procgloballist = &ProcGlobal->autovacFreeProcs; @@ -407,19 +420,6 @@ InitProcess(void) Assert(MyProc->procgloballist == procgloballist); /* - * Now that we have a PGPROC, mark ourselves as an active postmaster - * child; this is so that the postmaster can detect it if we exit without - * cleaning up. (XXX autovac launcher currently doesn't participate in - * this; it probably should.) - * - * Slot sync worker also does not participate in it, see comments atop - * 'struct bkend' in postmaster.c. - */ - if (IsUnderPostmaster && !AmAutoVacuumLauncherProcess() && - !AmLogicalSlotSyncWorkerProcess()) - MarkPostmasterChildActive(); - - /* * Initialize all fields of MyProc, except for those previously * initialized by InitProcGlobal. */ @@ -993,18 +993,6 @@ ProcKill(int code, Datum arg) SpinLockRelease(ProcStructLock); - /* - * This process is no longer present in shared memory in any meaningful - * way, so tell the postmaster we've cleaned up acceptably well. (XXX - * autovac launcher should be included here someday) - * - * Slot sync worker is also not a postmaster child, so skip this shared - * memory related processing here. - */ - if (IsUnderPostmaster && !AmAutoVacuumLauncherProcess() && - !AmLogicalSlotSyncWorkerProcess()) - MarkPostmasterChildInactive(); - /* wake autovac launcher if needed -- see comments in FreeWorkerInfo */ if (AutovacuumLauncherPid != 0) kill(AutovacuumLauncherPid, SIGUSR2); |