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

Commit3c4ab3f

Browse files
committed
Exit backend from SIGTERM or FATAL by simulating client EOF, rather than
calling proc_exit() directly. This should make SIGTERM more reliable.
1 parent1934055 commit3c4ab3f

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

‎src/backend/tcop/postgres.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.398 2004/04/07 05:05:49 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.399 2004/04/11 00:54:44 momjian Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -2938,7 +2938,10 @@ PostgresMain(int argc, char *argv[], const char *username)
29382938
/*
29392939
* (3) read a command (loop blocks here)
29402940
*/
2941-
firstchar=ReadCommand(&input_message);
2941+
if (!in_fatal_exit)
2942+
firstchar=ReadCommand(&input_message);
2943+
else
2944+
firstchar=EOF;
29422945

29432946
/*
29442947
* (4) disable async signal conditions again.
@@ -3170,7 +3173,8 @@ PostgresMain(int argc, char *argv[], const char *username)
31703173
* Otherwise it will fail to be called during other
31713174
* backend-shutdown scenarios.
31723175
*/
3173-
proc_exit(0);
3176+
proc_exit(!in_fatal_exit ?0 :proc_exit_inprogress||
3177+
!IsUnderPostmaster);
31743178

31753179
case'd':/* copy data */
31763180
case'c':/* copy done */

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.132 2004/04/05 03:02:06 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.133 2004/04/11 00:54:45 momjian Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -72,6 +72,8 @@ PGErrorVerbosity Log_error_verbosity = PGERROR_VERBOSE;
7272
char*Log_line_prefix=NULL;/* format for extra log line info */
7373
unsignedintLog_destination;
7474

75+
boolin_fatal_exit= false;
76+
7577
#ifdefHAVE_SYSLOG
7678
char*Syslog_facility;/* openlog() parameters */
7779
char*Syslog_ident;
@@ -442,7 +444,12 @@ errfinish(int dummy,...)
442444
*/
443445
fflush(stdout);
444446
fflush(stderr);
445-
proc_exit(proc_exit_inprogress|| !IsUnderPostmaster);
447+
448+
if (in_fatal_exit)
449+
ereport(PANIC, (errmsg("fatal error during fatal exit, giving up")));
450+
451+
/* We will exit the backend by simulating a client EOF */
452+
in_fatal_exit= true;
446453
}
447454

448455
/*

‎src/include/tcop/tcopprot.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.64 2004/04/07 05:05:50 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.65 2004/04/11 00:54:45 momjian Exp $
1111
*
1212
* OLD COMMENTS
1313
* This file was created so that other c files could get the two
@@ -34,6 +34,7 @@ extern bool log_hostname;
3434
externDLLIMPORTconstchar*debug_query_string;
3535
externchar*rendezvous_name;
3636
externintmax_stack_depth;
37+
externboolin_fatal_exit;
3738

3839
/* GUC-configurable parameters */
3940

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp