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

Commit16dc9ba

Browse files
committed
AbortOutOfAnyTransaction() just before backend exit, to ensure that
resources are cleaned up if the user disconnected mid-transaction.Great thanks to Hiroshi for pointing out what should have been obvious...
1 parent7bc654b commit16dc9ba

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

‎src/backend/tcop/postgres.c

Lines changed: 20 additions & 17 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.173 2000/08/29 09:36:47 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.174 2000/08/30 20:30:06 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -1404,14 +1404,14 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
14041404
if (!IsUnderPostmaster)
14051405
{
14061406
puts("\nPOSTGRES backend interactive interface ");
1407-
puts("$Revision: 1.173 $ $Date: 2000/08/29 09:36:47 $\n");
1407+
puts("$Revision: 1.174 $ $Date: 2000/08/30 20:30:06 $\n");
14081408
}
14091409

14101410
/*
14111411
* Initialize the deferred trigger manager
14121412
*/
14131413
if (DeferredTriggerInit()!=0)
1414-
proc_exit(0);
1414+
gotonormalexit;
14151415

14161416
SetProcessingMode(NormalProcessing);
14171417

@@ -1451,10 +1451,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
14511451
AbortCurrentTransaction();
14521452

14531453
if (ExitAfterAbort)
1454-
{
1455-
ProcReleaseLocks();/* Just to be sure... */
1456-
proc_exit(0);
1457-
}
1454+
gotoerrorexit;
1455+
14581456
/*
14591457
* If we recovered successfully, return to normal top-level context
14601458
* and clear ErrorContext for next time.
@@ -1547,8 +1545,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
15471545
if (HandleFunctionRequest()==EOF)
15481546
{
15491547
/* lost frontend connection during F message input */
1550-
pq_close();
1551-
proc_exit(0);
1548+
gotonormalexit;
15521549
}
15531550
break;
15541551

@@ -1607,11 +1604,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
16071604
*/
16081605
case'X':
16091606
caseEOF:
1610-
if (!IsUnderPostmaster)
1611-
ShutdownXLOG();
1612-
pq_close();
1613-
proc_exit(0);
1614-
break;
1607+
gotonormalexit;
16151608

16161609
default:
16171610
elog(ERROR,"unknown frontend message was received");
@@ -1649,10 +1642,20 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
16491642
*/
16501643
MemoryContextCheck(TopMemoryContext);
16511644
#endif
1652-
}/* infinite for-loop */
1645+
}/* end of main loop */
1646+
1647+
normalexit:
1648+
ExitAfterAbort= true;/* ensure we will exit if elog during abort */
1649+
AbortOutOfAnyTransaction();
1650+
if (!IsUnderPostmaster)
1651+
ShutdownXLOG();
1652+
1653+
errorexit:
1654+
pq_close();
1655+
ProcReleaseLocks();/* Just to be sure... */
1656+
proc_exit(0);
16531657

1654-
proc_exit(0);/* shouldn't get here... */
1655-
return1;
1658+
return1;/* keep compiler quiet */
16561659
}
16571660

16581661
#ifndefHAVE_GETRUSAGE

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp