mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Adjust elog.c so that elog(FATAL) exits (including cases where ERROR is
promoted to FATAL) end in exit(1) not exit(0). Then change the postmaster to allow exit(1) without a system-wide panic, but not for the startup subprocess or the bgwriter. There were a couple of places that were using exit(1) to deliberately force a system-wide panic; adjust these to be exit(2) instead. This fixes the problem noted back in July that if the startup process exits with elog(ERROR), the postmaster would think everything is hunky-dory and proceed to start up. Alternative solutions such as trying to run the entire startup process as a critical section seem less clean, primarily because of the fact that a fair amount of startup code is shared by all postmaster children in the EXEC_BACKEND case. We'd need an ugly special case somewhere near the head of main.c to make it work if it's the child process's responsibility to determine what happens; and what's the point when the postmaster already treats different children differently?
This commit is contained in:
@ -42,7 +42,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.175 2006/10/01 22:08:18 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.176 2006/11/21 00:49:55 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -421,25 +421,23 @@ errfinish(int dummy,...)
|
||||
* fflush here is just to improve the odds that we get to see the
|
||||
* error message, in case things are so hosed that proc_exit crashes.
|
||||
* Any other code you might be tempted to add here should probably be
|
||||
* in an on_proc_exit callback instead.
|
||||
* in an on_proc_exit or on_shmem_exit callback instead.
|
||||
*/
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
/*
|
||||
* If proc_exit is already running, we exit with nonzero exit code to
|
||||
* indicate that something's pretty wrong. We also want to exit with
|
||||
* nonzero exit code if not running under the postmaster (for example,
|
||||
* if we are being run from the initdb script, we'd better return an
|
||||
* error status).
|
||||
* Do normal process-exit cleanup, then return exit code 1 to indicate
|
||||
* FATAL termination. The postmaster may or may not consider this
|
||||
* worthy of panic, depending on which subprocess returns it.
|
||||
*/
|
||||
proc_exit(proc_exit_inprogress || !IsUnderPostmaster);
|
||||
proc_exit(1);
|
||||
}
|
||||
|
||||
if (elevel >= PANIC)
|
||||
{
|
||||
/*
|
||||
* Serious crash time. Postmaster will observe nonzero process exit
|
||||
* Serious crash time. Postmaster will observe SIGABRT process exit
|
||||
* status and kill the other backends too.
|
||||
*
|
||||
* XXX: what if we are *in* the postmaster? abort() won't kill our
|
||||
|
Reference in New Issue
Block a user