1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +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:
Tom Lane
2000-12-18 00:44:50 +00:00
parent 8c8ed4f456
commit a626b78c89
14 changed files with 255 additions and 139 deletions

View File

@ -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();