diff options
author | Tom Lane | 2000-12-18 00:44:50 +0000 |
---|---|---|
committer | Tom Lane | 2000-12-18 00:44:50 +0000 |
commit | a626b78c8957f50ae6345015b249e996d9aab55d (patch) | |
tree | 352a378cead2660c6c4a1704007cfb0d96f96183 /src/backend/access | |
parent | 8c8ed4f456f0b343d5df332e0ff31c6bb889429f (diff) |
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.
Diffstat (limited to 'src/backend/access')
-rw-r--r-- | src/backend/access/transam/xact.c | 30 | ||||
-rw-r--r-- | src/backend/access/transam/xlog.c | 12 |
2 files changed, 22 insertions, 20 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 6cd089fd959..c8c9e680f5f 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -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(); diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 3b2c5461dcd..ba85f4b60d0 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -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"); } |