Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite1492cc

Browse files
committed
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 thatelog(ERROR) or elog(FATAL) in the postmaster or during backend startupnow 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 beforced to quit too? But I don't understand Vadim's recent changes inthis area, so I'll leave it to him to look over and tweak if needed.
1 parentdc5c771 commite1492cc

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

‎src/backend/tcop/postgres.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.136 1999/10/25 03:07:48 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.137 1999/11/16 06:13:35 tgl Exp $
1111
*
1212
* NOTES
1313
* this is the "main" module of the postgres backend and
@@ -116,6 +116,7 @@ static bool IsEmptyQuery = false;
116116
/* note: these declarations had better match tcopprot.h */
117117
DLLIMPORTsigjmp_bufWarn_restart;
118118

119+
boolWarn_restart_ready= false;
119120
boolInError= false;
120121
boolExitAfterAbort= false;
121122

@@ -748,7 +749,7 @@ pg_exec_query_dest(char *query_string,/* string to execute */
748749
*Some backend has bought the farm,
749750
*so we need to stop what we're doing and exit.
750751
*
751-
*die() performs an orderly cleanup viaExitPostgres()
752+
*die() performs an orderly cleanup viaproc_exit()
752753
* --------------------------------
753754
*/
754755

@@ -771,7 +772,7 @@ quickdie(SIGNAL_ARGS)
771772

772773

773774
/*
774-
* DO NOTExitPostgres(0) -- we're here because shared memory may be
775+
* DO NOTproc_exit(0) -- we're here because shared memory may be
775776
* corrupted, so we don't want to flush any shared state to stable
776777
* storage. Just nail the windows shut and get out of town.
777778
*/
@@ -1494,14 +1495,16 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
14941495
if (!IsUnderPostmaster)
14951496
{
14961497
puts("\nPOSTGRES backend interactive interface ");
1497-
puts("$Revision: 1.136 $ $Date: 1999/10/25 03:07:48 $\n");
1498+
puts("$Revision: 1.137 $ $Date: 1999/11/16 06:13:35 $\n");
14981499
}
14991500

15001501
/*
15011502
* Initialize the deferred trigger manager
15021503
*/
15031504
if (DeferredTriggerInit()!=0)
1504-
ExitPostgres(1);
1505+
proc_exit(1);
1506+
1507+
SetProcessingMode(NormalProcessing);
15051508

15061509
/*
15071510
* POSTGRES main processing loop begins here
@@ -1510,8 +1513,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
15101513
* so we abort the current transaction and start a new one.
15111514
*/
15121515

1513-
SetProcessingMode(NormalProcessing);
1514-
15151516
if (sigsetjmp(Warn_restart,1)!=0)
15161517
{
15171518
time(&tim);
@@ -1524,10 +1525,12 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
15241525
if (ExitAfterAbort)
15251526
{
15261527
ProcReleaseLocks();/* Just to be sure... */
1527-
ExitPostgres(0);
1528+
proc_exit(0);
15281529
}
15291530
}
15301531

1532+
Warn_restart_ready= true;/* we can now handle elog(ERROR) */
1533+
15311534
PG_SETMASK(&UnBlockSig);
15321535

15331536
/*

‎src/backend/utils/error/elog.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.50 1999/10/25 03:07:50 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.51 1999/11/16 06:13:36 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -378,12 +378,13 @@ elog(int lev, const char *fmt, ...)
378378
}
379379
InError= true;
380380
ProcReleaseSpins(NULL);/* get rid of spinlocks we hold */
381-
if (lev==FATAL)
381+
if (!Warn_restart_ready)
382382
{
383-
if (IsInitProcessingMode())
384-
ExitPostgres(0);
385-
ExitAfterAbort= true;
383+
/* error reported before there is a main loop to return to */
384+
elog(REALLYFATAL,"elog: error in postmaster or backend startup, giving up!");
386385
}
386+
if (lev==FATAL)
387+
ExitAfterAbort= true;
387388
/* exit to main loop */
388389
siglongjmp(Warn_restart,1);
389390
}
@@ -393,6 +394,9 @@ elog(int lev, const char *fmt, ...)
393394
/*
394395
* Serious crash time. Postmaster will observe nonzero
395396
* process exit status and kill the other backends too.
397+
*
398+
* XXX: what if we are *in* the postmaster? proc_exit()
399+
* won't kill our children...
396400
*/
397401
fflush(stdout);
398402
fflush(stderr);

‎src/include/tcop/tcopprot.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: tcopprot.h,v 1.22 1999/10/06 21:58:18 vadim Exp $
9+
* $Id: tcopprot.h,v 1.23 1999/11/16 06:13:34 tgl Exp $
1010
*
1111
* OLD COMMENTS
1212
* This file was created so that other c files could get the two
@@ -37,6 +37,7 @@
3737
#definesiglongjmp longjmp
3838
#endif
3939
externDLLIMPORTsigjmp_bufWarn_restart;
40+
externboolWarn_restart_ready;
4041
externboolInError;
4142
externboolExitAfterAbort;
4243

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp