aboutsummaryrefslogtreecommitdiff
path: root/src/backend/postmaster
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/postmaster')
-rw-r--r--src/backend/postmaster/bgwriter.c43
-rw-r--r--src/backend/postmaster/postmaster.c8
2 files changed, 29 insertions, 22 deletions
diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c
index f0ecb13d27a..0da107f9e13 100644
--- a/src/backend/postmaster/bgwriter.c
+++ b/src/backend/postmaster/bgwriter.c
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.3 2004/06/03 02:08:03 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.4 2004/07/31 00:45:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -57,6 +57,7 @@
#include "storage/smgr.h"
#include "tcop/tcopprot.h"
#include "utils/guc.h"
+#include "utils/memutils.h"
/*----------
@@ -153,6 +154,8 @@ static void ReqShutdownHandler(SIGNAL_ARGS);
void
BackgroundWriterMain(void)
{
+ sigjmp_buf local_sigjmp_buf;
+
Assert(BgWriterShmem != NULL);
BgWriterShmem->bgwriter_pid = MyProcPid;
am_bg_writer = true;
@@ -201,19 +204,19 @@ BackgroundWriterMain(void)
/*
* If an exception is encountered, processing resumes here.
+ *
+ * See notes in postgres.c about the design of this coding.
*/
- if (sigsetjmp(Warn_restart, 1) != 0)
+ if (sigsetjmp(local_sigjmp_buf, 1) != 0)
{
- /*
- * Make sure we're not interrupted while cleaning up. Also forget
- * any pending QueryCancel request, since we're aborting anyway.
- * Force InterruptHoldoffCount to a known state in case we
- * ereport'd from inside a holdoff section.
- */
- ImmediateInterruptOK = false;
- QueryCancelPending = false;
- InterruptHoldoffCount = 1;
- CritSectionCount = 0; /* should be unnecessary, but... */
+ /* Since not using PG_TRY, must reset error stack by hand */
+ error_context_stack = NULL;
+
+ /* Prevent interrupts while cleaning up */
+ HOLD_INTERRUPTS();
+
+ /* Report the error to the server log */
+ EmitErrorReport();
/*
* These operations are really just a minimal subset of
@@ -224,12 +227,6 @@ BackgroundWriterMain(void)
AbortBufferIO();
UnlockBuffers();
- /*
- * Clear flag to indicate that we got out of error recovery mode
- * successfully. (Flag was set in elog.c before longjmp().)
- */
- InError = false;
-
/* Warn any waiting backends that the checkpoint failed. */
if (ckpt_active)
{
@@ -242,8 +239,13 @@ BackgroundWriterMain(void)
}
/*
- * Exit interrupt holdoff section we implicitly established above.
+ * Now return to normal top-level context and clear ErrorContext
+ * for next time.
*/
+ MemoryContextSwitchTo(TopMemoryContext);
+ FlushErrorState();
+
+ /* Now we can allow interrupts again */
RESUME_INTERRUPTS();
/*
@@ -255,7 +257,8 @@ BackgroundWriterMain(void)
pg_usleep(1000000L);
}
- Warn_restart_ready = true; /* we can now handle ereport(ERROR) */
+ /* We can now handle ereport(ERROR) */
+ PG_exception_stack = &local_sigjmp_buf;
/*
* Unblock signals (they were blocked when the postmaster forked us)
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index eace246071b..e144b6eaa93 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.416 2004/07/27 01:46:03 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.417 2004/07/31 00:45:33 tgl Exp $
*
* NOTES
*
@@ -73,7 +73,6 @@
#include <ctype.h>
#include <sys/stat.h>
#include <sys/socket.h>
-#include <errno.h>
#include <fcntl.h>
#include <sys/param.h>
#include <netinet/in.h>
@@ -3226,6 +3225,11 @@ StartChildProcess(int xlop)
/* Lose the postmaster's on-exit routines and port connections */
on_exit_reset();
+ /* Release postmaster's working memory context */
+ MemoryContextSwitchTo(TopMemoryContext);
+ MemoryContextDelete(PostmasterContext);
+ PostmasterContext = NULL;
+
BootstrapMain(ac, av);
ExitPostmaster(0);
}