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

Commitcb7ce7d

Browse files
committed
Fix recent breakage of query-cancel logic, see my pghackers message
of 6 Jan 2001 21:55.
1 parent6781aa4 commitcb7ce7d

File tree

4 files changed

+65
-36
lines changed

4 files changed

+65
-36
lines changed

‎src/backend/tcop/postgres.c

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.198 2000/12/20 21:51:52 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.199 2001/01/07 04:17:29 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -94,7 +94,7 @@ DLLIMPORT sigjmp_buf Warn_restart;
9494

9595
boolWarn_restart_ready= false;
9696
boolInError= false;
97-
boolProcDiePending= false;
97+
volatileboolProcDiePending= false;
9898

9999
staticboolEchoQuery= false;/* default don't echo */
100100
charpg_pathname[MAXPGPATH];
@@ -920,7 +920,10 @@ finish_xact_command(void)
920920
void
921921
handle_warn(SIGNAL_ARGS)
922922
{
923-
/* Don't joggle the elbow of a critical section */
923+
/* Don't joggle the elbow of proc_exit */
924+
if (proc_exit_inprogress)
925+
return;
926+
/* Don't joggle the elbow of a critical section, either */
924927
if (CritSectionCount>0)
925928
{
926929
QueryCancel= true;
@@ -956,28 +959,38 @@ quickdie(SIGNAL_ARGS)
956959
void
957960
die(SIGNAL_ARGS)
958961
{
962+
intsave_errno=errno;
963+
959964
PG_SETMASK(&BlockSig);
960965

961-
/* Don't joggle the elbow of a critical section */
966+
/* Don't joggle the elbow of proc_exit */
967+
if (proc_exit_inprogress)
968+
{
969+
errno=save_errno;
970+
return;
971+
}
972+
/* Don't joggle the elbow of a critical section, either */
962973
if (CritSectionCount>0)
963974
{
964-
QueryCancel= true;
965975
ProcDiePending= true;
976+
errno=save_errno;
966977
return;
967978
}
968-
/* Don't joggle the elbow of proc_exit, either */
969-
if (proc_exit_inprogress)
970-
return;
971-
elog(FATAL,"The system is shutting down");
979+
/* Otherwise force immediate proc_exit */
980+
ForceProcDie();
972981
}
973982

974-
/* signal handler for floating point exception */
975-
staticvoid
976-
FloatExceptionHandler(SIGNAL_ARGS)
983+
/*
984+
* This is split out of die() so that it can be invoked later from
985+
* END_CRIT_CODE.
986+
*/
987+
void
988+
ForceProcDie(void)
977989
{
978-
elog(ERROR,"floating point exception!"
979-
" The last floating point operation either exceeded legal ranges"
980-
" or was a divide by zero");
990+
/* Reset flag to avoid another elog() during shutdown */
991+
ProcDiePending= false;
992+
/* Send error message and do proc_exit() */
993+
elog(FATAL,"The system is shutting down");
981994
}
982995

983996
/* signal handler for query cancel signal from postmaster */
@@ -986,22 +999,41 @@ QueryCancelHandler(SIGNAL_ARGS)
986999
{
9871000
intsave_errno=errno;
9881001

1002+
/* Don't joggle the elbow of proc_exit, nor an already-in-progress abort */
1003+
if (proc_exit_inprogress||InError)
1004+
{
1005+
errno=save_errno;
1006+
return;
1007+
}
1008+
1009+
/* Set flag to cause CancelQuery to be called when it's safe */
9891010
QueryCancel= true;
1011+
1012+
/* If we happen to be waiting for a lock, get out of that */
9901013
LockWaitCancel();
1014+
1015+
/* Otherwise, bide our time... */
9911016
errno=save_errno;
9921017
}
9931018

9941019
void
9951020
CancelQuery(void)
9961021
{
997-
998-
/*
999-
* QueryCancel flag will be reset in main loop, which we reach by
1000-
* longjmp from elog().
1001-
*/
1022+
/* Reset flag to avoid another elog() during error recovery */
1023+
QueryCancel= false;
1024+
/* Create an artificial error condition to get out of query */
10021025
elog(ERROR,"Query was cancelled.");
10031026
}
10041027

1028+
/* signal handler for floating point exception */
1029+
staticvoid
1030+
FloatExceptionHandler(SIGNAL_ARGS)
1031+
{
1032+
elog(ERROR,"floating point exception!"
1033+
" The last floating point operation either exceeded legal ranges"
1034+
" or was a divide by zero");
1035+
}
1036+
10051037
staticvoid
10061038
SigHupHandler(SIGNAL_ARGS)
10071039
{
@@ -1651,7 +1683,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
16511683
if (!IsUnderPostmaster)
16521684
{
16531685
puts("\nPOSTGRES backend interactive interface ");
1654-
puts("$Revision: 1.198 $ $Date:2000/12/20 21:51:52 $\n");
1686+
puts("$Revision: 1.199 $ $Date:2001/01/07 04:17:29 $\n");
16551687
}
16561688

16571689
/*

‎src/backend/utils/init/globals.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.48 2000/12/28 13:00:24 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.49 2001/01/07 04:17:29 tgl Exp $
1212
*
1313
* NOTES
1414
* Globals used all over the place should be declared here and not
@@ -34,7 +34,7 @@ ProtocolVersion FrontendProtocol = PG_PROTOCOL_LATEST;
3434

3535
boolNoversion= false;
3636
boolQuiet= false;
37-
boolQueryCancel= false;
37+
volatileboolQueryCancel= false;
3838

3939
intMyProcPid;
4040
structPort*MyProcPort;

‎src/include/miscadmin.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: miscadmin.h,v 1.75 2000/11/29 20:59:54 tgl Exp $
15+
* $Id: miscadmin.h,v 1.76 2001/01/07 04:17:28 tgl Exp $
1616
*
1717
* NOTES
1818
* some of the information in this file will be moved to
@@ -42,7 +42,7 @@ extern intPostmasterMain(int argc, char *argv[]);
4242
*/
4343
externboolNoversion;
4444
externboolQuiet;
45-
externboolQueryCancel;
45+
externvolatileboolQueryCancel;
4646
externchar*DataDir;
4747

4848
externintMyProcPid;

‎src/include/utils/elog.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: elog.h,v 1.21 2000/12/18 00:44:50 tgl Exp $
10+
* $Id: elog.h,v 1.22 2001/01/07 04:17:28 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -30,11 +30,13 @@ extern int Use_syslog;
3030
/*
3131
* If CritSectionCount > 0, signal handlers mustn't do
3232
* elog(ERROR|FATAL), instead remember what action is
33-
* required with QueryCancel & ProcDiePending.
33+
* required with QueryCancel or ProcDiePending.
34+
* ProcDiePending will be honored at critical section exit,
35+
* but QueryCancel is only checked at specified points.
3436
*/
3537
externuint32CritSectionCount;/* duplicates access/xlog.h */
36-
externboolQueryCancel;/* duplicates miscadmin.h */
37-
externboolProcDiePending;
38+
externvolatileboolProcDiePending;
39+
externvoidForceProcDie(void);/* in postgres.c */
3840

3941
#defineSTART_CRIT_CODE(CritSectionCount++)
4042

@@ -43,13 +45,8 @@ extern boolProcDiePending;
4345
if (CritSectionCount == 0) \
4446
elog(STOP, "Not in critical section"); \
4547
CritSectionCount--; \
46-
if (CritSectionCount == 0 && QueryCancel) \
47-
{ \
48-
if (ProcDiePending) \
49-
elog(FATAL, "The system is shutting down"); \
50-
else \
51-
elog(ERROR, "Query was cancelled."); \
52-
} \
48+
if (CritSectionCount == 0 && ProcDiePending) \
49+
ForceProcDie(); \
5350
} while(0)
5451

5552
externboolLog_timestamp;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp