summaryrefslogtreecommitdiff
path: root/src/backend/postmaster/postmaster.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2007-06-25 16:09:03 +0000
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2007-06-25 16:09:03 +0000
commitbae0b56880f5187c3e75bb8bcb4f04da6b6bbc4f (patch)
tree3bcb1f7764e9c297b347a7b2ee2bfa0bd2e10a3e /src/backend/postmaster/postmaster.c
parent46379d6e60f0f95e127a5045ca1fa74dfdc48a85 (diff)
downloadpostgresql-bae0b56880f5187c3e75bb8bcb4f04da6b6bbc4f.tar.gz
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.
Diffstat (limited to 'src/backend/postmaster/postmaster.c')
-rw-r--r--src/backend/postmaster/postmaster.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 385185eddb..cb060878a9 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -37,7 +37,7 @@
*
*
* 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
*
@@ -3830,32 +3830,35 @@ StartAutovacuumWorker(void)
return;
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->is_autovacuum = true;
- /* we don't need a cancel key */
+ bn->pid = StartAutoVacWorker();
+ bn->is_autovacuum = true;
+ /* we don't need a cancel key */
- if (bn->pid > 0)
- {
- DLAddHead(BackendList, DLNewElem(bn));
+ if (bn->pid > 0)
+ {
+ DLAddHead(BackendList, DLNewElem(bn));
#ifdef EXEC_BACKEND
- ShmemBackendArrayAdd(bn);
+ ShmemBackendArrayAdd(bn);
#endif
- }
- else
- {
- /* not much we can do */
- ereport(LOG,
- (errmsg("could not fork new process for autovacuum: %m")));
+ /* all OK */
+ return;
+ }
+
+ /*
+ * fork failed, fall through to report -- actual error message was
+ * logged by StartAutoVacWorker
+ */
free(bn);
}
+ else
+ elog(LOG, "out of memory");
+
+ /* report the failure to the launcher */
+ AutoVacWorkerFailed();
+ if (AutoVacPID != 0)
+ kill(AutoVacPID, SIGUSR1);
}
/*