mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Clean up backend-exit-time cleanup behavior. Use on_shmem_exit callbacks
to ensure that we have released buffer refcounts and so forth, rather than putting ad-hoc operations before (some of the calls to) proc_exit. Add commentary to discourage future hackers from repeating that mistake.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.88 2000/12/07 10:03:46 inoue Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.89 2000/12/18 00:44:45 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Transaction aborts can now occur two ways:
|
||||
@@ -1095,6 +1095,15 @@ AbortTransaction(void)
|
||||
MyProc->xmin = InvalidTransactionId;
|
||||
}
|
||||
|
||||
/*
|
||||
* Release any spinlocks or buffer context locks we might be holding
|
||||
* as quickly as possible. (Real locks, however, must be held till
|
||||
* we finish aborting.) Releasing spinlocks is critical since we
|
||||
* might try to grab them again while cleaning up!
|
||||
*/
|
||||
ProcReleaseSpins(NULL);
|
||||
UnlockBuffers();
|
||||
|
||||
/* ----------------
|
||||
* check the current transaction state
|
||||
* ----------------
|
||||
@@ -1105,18 +1114,6 @@ AbortTransaction(void)
|
||||
if (s->state != TRANS_INPROGRESS)
|
||||
elog(NOTICE, "AbortTransaction and not in in-progress state");
|
||||
|
||||
/*
|
||||
* Reset user id which might have been changed transiently
|
||||
*/
|
||||
SetUserId(GetSessionUserId());
|
||||
|
||||
/* ----------------
|
||||
* Tell the trigger manager that this transaction is about to be
|
||||
* aborted.
|
||||
* ----------------
|
||||
*/
|
||||
DeferredTriggerAbortXact();
|
||||
|
||||
/* ----------------
|
||||
* set the current transaction state information
|
||||
* appropriately during the abort processing
|
||||
@@ -1124,12 +1121,17 @@ AbortTransaction(void)
|
||||
*/
|
||||
s->state = TRANS_ABORT;
|
||||
|
||||
/*
|
||||
* Reset user id which might have been changed transiently
|
||||
*/
|
||||
SetUserId(GetSessionUserId());
|
||||
|
||||
/* ----------------
|
||||
* do abort processing
|
||||
* ----------------
|
||||
*/
|
||||
DeferredTriggerAbortXact();
|
||||
lo_commit(false); /* 'false' means it's abort */
|
||||
UnlockBuffers();
|
||||
AtAbort_Notify();
|
||||
CloseSequences();
|
||||
AtEOXact_portals();
|
||||
|
||||
@@ -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.42 2000/12/11 19:27:42 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.43 2000/12/18 00:44:45 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
int XLOGbuffers = 8;
|
||||
XLogRecPtr MyLastRecPtr = {0, 0};
|
||||
uint32 StopIfError = 0;
|
||||
uint32 CritSectionCount = 0;
|
||||
bool InRecovery = false;
|
||||
StartUpID ThisStartUpID = 0;
|
||||
|
||||
@@ -1531,7 +1531,7 @@ StartupXLOG()
|
||||
char buffer[MAXLOGRECSZ + SizeOfXLogRecord];
|
||||
|
||||
elog(LOG, "starting up");
|
||||
StopIfError++;
|
||||
CritSectionCount++;
|
||||
|
||||
XLogCtl->xlblocks = (XLogRecPtr *) (((char *) XLogCtl) + sizeof(XLogCtlData));
|
||||
XLogCtl->pages = ((char *) XLogCtl->xlblocks + sizeof(XLogRecPtr) * XLOGbuffers);
|
||||
@@ -1748,7 +1748,7 @@ StartupXLOG()
|
||||
XLogCtl->ThisStartUpID = ThisStartUpID;
|
||||
|
||||
elog(LOG, "database system is in production state");
|
||||
StopIfError--;
|
||||
CritSectionCount--;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1771,10 +1771,10 @@ ShutdownXLOG()
|
||||
{
|
||||
elog(LOG, "shutting down");
|
||||
|
||||
StopIfError++;
|
||||
CritSectionCount++;
|
||||
CreateDummyCaches();
|
||||
CreateCheckPoint(true);
|
||||
StopIfError--;
|
||||
CritSectionCount--;
|
||||
|
||||
elog(LOG, "database system is shut down");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user