mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Modify elog() logic so that it won't try to longjmp(Warn_restart) before
Warn_restart has been set by the backend main loop. This means that elog(ERROR) or elog(FATAL) in the postmaster or during backend startup now have well-defined behavior: proc_exit() rather than coredump. In the case of elog() inside the postmaster, I think that proc_exit() is probably not enough --- don't we want our child backends to be forced to quit too? But I don't understand Vadim's recent changes in this area, so I'll leave it to him to look over and tweak if needed.
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.136 1999/10/25 03:07:48 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.137 1999/11/16 06:13:35 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@ -116,6 +116,7 @@ static bool IsEmptyQuery = false;
|
||||
/* note: these declarations had better match tcopprot.h */
|
||||
DLLIMPORT sigjmp_buf Warn_restart;
|
||||
|
||||
bool Warn_restart_ready = false;
|
||||
bool InError = false;
|
||||
bool ExitAfterAbort = false;
|
||||
|
||||
@ -748,7 +749,7 @@ pg_exec_query_dest(char *query_string, /* string to execute */
|
||||
* Some backend has bought the farm,
|
||||
* so we need to stop what we're doing and exit.
|
||||
*
|
||||
* die() performs an orderly cleanup via ExitPostgres()
|
||||
* die() performs an orderly cleanup via proc_exit()
|
||||
* --------------------------------
|
||||
*/
|
||||
|
||||
@ -771,7 +772,7 @@ quickdie(SIGNAL_ARGS)
|
||||
|
||||
|
||||
/*
|
||||
* DO NOT ExitPostgres(0) -- we're here because shared memory may be
|
||||
* DO NOT proc_exit(0) -- we're here because shared memory may be
|
||||
* corrupted, so we don't want to flush any shared state to stable
|
||||
* storage. Just nail the windows shut and get out of town.
|
||||
*/
|
||||
@ -1494,14 +1495,16 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
puts("\nPOSTGRES backend interactive interface ");
|
||||
puts("$Revision: 1.136 $ $Date: 1999/10/25 03:07:48 $\n");
|
||||
puts("$Revision: 1.137 $ $Date: 1999/11/16 06:13:35 $\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the deferred trigger manager
|
||||
*/
|
||||
if (DeferredTriggerInit() != 0)
|
||||
ExitPostgres(1);
|
||||
proc_exit(1);
|
||||
|
||||
SetProcessingMode(NormalProcessing);
|
||||
|
||||
/*
|
||||
* POSTGRES main processing loop begins here
|
||||
@ -1510,8 +1513,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
|
||||
* so we abort the current transaction and start a new one.
|
||||
*/
|
||||
|
||||
SetProcessingMode(NormalProcessing);
|
||||
|
||||
if (sigsetjmp(Warn_restart, 1) != 0)
|
||||
{
|
||||
time(&tim);
|
||||
@ -1524,10 +1525,12 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
|
||||
if (ExitAfterAbort)
|
||||
{
|
||||
ProcReleaseLocks(); /* Just to be sure... */
|
||||
ExitPostgres(0);
|
||||
proc_exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
Warn_restart_ready = true; /* we can now handle elog(ERROR) */
|
||||
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user