1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-09 06:21:09 +03:00

Restructure backend SIGINT/SIGTERM handling so that 'die' interrupts

are treated more like 'cancel' interrupts: the signal handler sets a
flag that is examined at well-defined spots, rather than trying to cope
with an interrupt that might happen anywhere.  See pghackers discussion
of 1/12/01.
This commit is contained in:
Tom Lane
2001-01-14 05:08:17 +00:00
parent 027f144e39
commit 36839c1927
24 changed files with 614 additions and 479 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.73 2001/01/12 21:53:55 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.74 2001/01/14 05:08:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,6 +17,7 @@
#include "access/heapam.h"
#include "access/nbtree.h"
#include "miscadmin.h"
typedef struct

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.92 2001/01/12 21:53:56 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.93 2001/01/14 05:08:14 tgl Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@@ -1015,6 +1015,9 @@ CommitTransaction(void)
if (s->state != TRANS_INPROGRESS)
elog(NOTICE, "CommitTransaction and not in in-progress state ");
/* Prevent cancel/die interrupt while cleaning up */
START_CRIT_SECTION();
/* ----------------
* Tell the trigger manager that this transaction is about to be
* committed. He'll invoke all trigger deferred until XACT before
@@ -1083,6 +1086,8 @@ CommitTransaction(void)
* ----------------
*/
s->state = TRANS_DEFAULT;
END_CRIT_SECTION();
}
/* --------------------------------
@@ -1095,6 +1100,9 @@ AbortTransaction(void)
{
TransactionState s = CurrentTransactionState;
/* Prevent cancel/die interrupt while cleaning up */
START_CRIT_SECTION();
/*
* Let others to know about no transaction in progress - vadim
* 11/26/96
@@ -1113,13 +1121,21 @@ AbortTransaction(void)
*/
ProcReleaseSpins(NULL);
UnlockBuffers();
/*
* Also clean up any open wait for lock, since the lock manager
* will choke if we try to wait for another lock before doing this.
*/
LockWaitCancel();
/* ----------------
* check the current transaction state
* ----------------
*/
if (s->state == TRANS_DISABLED)
{
END_CRIT_SECTION();
return;
}
if (s->state != TRANS_INPROGRESS)
elog(NOTICE, "AbortTransaction and not in in-progress state");
@@ -1169,6 +1185,7 @@ AbortTransaction(void)
* State remains TRANS_ABORT until CleanupTransaction().
* ----------------
*/
END_CRIT_SECTION();
}
/* --------------------------------

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.49 2001/01/12 21:53:56 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.50 2001/01/14 05:08:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -42,7 +42,6 @@
int XLOGbuffers = 8;
int XLOGfiles = 0; /* how many files to pre-allocate */
XLogRecPtr MyLastRecPtr = {0, 0};
volatile uint32 CritSectionCount = 0;
bool InRecovery = false;
StartUpID ThisStartUpID = 0;
XLogRecPtr RedoRecPtr;