Commit bae0b568 authored by Alvaro Herrera's avatar Alvaro Herrera

Improve autovacuum launcher's ability to detect a problem in worker startup,

by having the postmaster signal it when certain failures occur.  This requires
the postmaster setting a flag in shared memory, but should be as safe as the
pmsignal.c code is.

Also make sure the launcher honor's a postgresql.conf change turning it off
on SIGHUP.
parent 46379d6e
This diff is collapsed.
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.527 2007/03/22 19:53:30 momjian Exp $ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.528 2007/06/25 16:09:03 alvherre Exp $
* *
* NOTES * NOTES
* *
...@@ -3830,14 +3830,8 @@ StartAutovacuumWorker(void) ...@@ -3830,14 +3830,8 @@ StartAutovacuumWorker(void)
return; return;
bn = (Backend *) malloc(sizeof(Backend)); bn = (Backend *) malloc(sizeof(Backend));
if (!bn) if (bn)
{ {
ereport(LOG,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
return;
}
bn->pid = StartAutoVacWorker(); bn->pid = StartAutoVacWorker();
bn->is_autovacuum = true; bn->is_autovacuum = true;
/* we don't need a cancel key */ /* we don't need a cancel key */
...@@ -3848,14 +3842,23 @@ StartAutovacuumWorker(void) ...@@ -3848,14 +3842,23 @@ StartAutovacuumWorker(void)
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
ShmemBackendArrayAdd(bn); ShmemBackendArrayAdd(bn);
#endif #endif
/* all OK */
return;
} }
else
{ /*
/* not much we can do */ * fork failed, fall through to report -- actual error message was
ereport(LOG, * logged by StartAutoVacWorker
(errmsg("could not fork new process for autovacuum: %m"))); */
free(bn); free(bn);
} }
else
elog(LOG, "out of memory");
/* report the failure to the launcher */
AutoVacWorkerFailed();
if (AutoVacPID != 0)
kill(AutoVacPID, SIGUSR1);
} }
/* /*
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/postmaster/autovacuum.h,v 1.10 2007/04/18 16:44:18 alvherre Exp $ * $PostgreSQL: pgsql/src/include/postmaster/autovacuum.h,v 1.11 2007/06/25 16:09:03 alvherre Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -42,6 +42,8 @@ extern bool IsAutoVacuumWorkerProcess(void); ...@@ -42,6 +42,8 @@ extern bool IsAutoVacuumWorkerProcess(void);
extern void autovac_init(void); extern void autovac_init(void);
extern int StartAutoVacLauncher(void); extern int StartAutoVacLauncher(void);
extern int StartAutoVacWorker(void); extern int StartAutoVacWorker(void);
/* called from postmaster when a worker could not be forked */
extern void AutoVacWorkerFailed(void);
/* autovacuum cost-delay balancer */ /* autovacuum cost-delay balancer */
extern void AutoVacuumUpdateDelay(void); extern void AutoVacuumUpdateDelay(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment