/* Pointer to my own WorkerInfo, valid on each worker */
static WorkerInfo MyWorkerInfo = NULL;
-/* PID of launcher, valid only in worker while shutting down */
-int AutovacuumLauncherPid = 0;
-
static Oid do_start_worker(void);
static void ProcessAutoVacLauncherInterrupts(void);
pg_noreturn static void AutoVacLauncherShutdown(void);
do_autovacuum();
}
- /*
- * The launcher will be notified of my death in ProcKill, *if* we managed
- * to get a worker slot at all
- */
-
/* All done, go away */
proc_exit(0);
}
{
LWLockAcquire(AutovacuumLock, LW_EXCLUSIVE);
- /*
- * Wake the launcher up so that he can launch a new worker immediately
- * if required. We only save the launcher's PID in local memory here;
- * the actual signal will be sent when the PGPROC is recycled. Note
- * that we always do this, so that the launcher can rebalance the cost
- * limit setting of the remaining workers.
- *
- * We somewhat ignore the risk that the launcher changes its PID
- * between us reading it and the actual kill; we expect ProcKill to be
- * called shortly after us, and we assume that PIDs are not reused too
- * quickly after a process exits.
- */
- AutovacuumLauncherPid = AutoVacuumShmem->av_launcherpid;
-
dlist_delete(&MyWorkerInfo->wi_links);
MyWorkerInfo->wi_dboid = InvalidOid;
MyWorkerInfo->wi_tableoid = InvalidOid;
if (bp_bgworker_notify)
BackgroundWorkerStopNotifications(bp_pid);
+ /*
+ * If it was an autovacuum worker, wake up the launcher so that it can
+ * immediately launch a new worker or rebalance to cost limit setting of
+ * the remaining workers.
+ */
+ if (bp_bkend_type == B_AUTOVAC_WORKER && AutoVacLauncherPMChild != NULL)
+ signal_child(AutoVacLauncherPMChild, SIGUSR2);
+
/*
* If it was a background worker, also update its RegisteredBgWorker
* entry.
ProcGlobal->spins_per_delay = update_spins_per_delay(ProcGlobal->spins_per_delay);
SpinLockRelease(ProcStructLock);
-
- /* wake autovac launcher if needed -- see comments in FreeWorkerInfo */
- if (AutovacuumLauncherPid != 0)
- kill(AutovacuumLauncherPid, SIGUSR2);
}
/*
extern PGDLLIMPORT double autovacuum_vac_cost_delay;
extern PGDLLIMPORT int autovacuum_vac_cost_limit;
-/* autovacuum launcher PID, only valid when worker is shutting down */
-extern PGDLLIMPORT int AutovacuumLauncherPid;
-
extern PGDLLIMPORT int Log_autovacuum_min_duration;
extern PGDLLIMPORT int Log_autoanalyze_min_duration;