From 68693317d2896934628667f97c3dfec9b2c11ea3 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Sat, 15 Oct 2011 06:57:18 -0400 Subject: [PATCH] Simplify ProcArrayRemove(). --- src/backend/access/transam/twophase.c | 2 +- src/backend/storage/ipc/procarray.c | 25 +++---------------------- src/backend/storage/lmgr/proc.c | 2 +- src/include/storage/procarray.h | 2 +- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 058ea19262..4505918ef6 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -1310,7 +1310,7 @@ FinishPreparedTransaction(const char *gid, bool isCommit) hdr->nsubxacts, children, hdr->nabortrels, abortrels); - ProcArrayRemove(&gxact->proc, latestXid); + ProcArrayRemove(&gxact->proc); SnapArrayRemoveRunningXids(xid, hdr->nsubxacts, children, latestXid); /* diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index 695e3bb33b..5145e5b054 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -236,15 +236,11 @@ ProcArrayAdd(PGPROC *proc) /* * Remove the specified PGPROC from the shared array. * - * When latestXid is a valid XID, we are removing a live 2PC gxact from the - * array, and thus causing it to appear as "not running" anymore. In this - * case we must advance latestCompletedXid. (This is essentially the same - * as ProcArrayEndTransaction followed by removal of the PGPROC, but we take - * the ProcArrayLock only once, and don't damage the content of the PGPROC; - * twophase.c depends on the latter.) + * (This is similar to ProcArrayEndTransaction, but we don't damage the content + * of the PGPROC; twophase.c depends on the this.) */ void -ProcArrayRemove(PGPROC *proc, TransactionId latestXid) +ProcArrayRemove(PGPROC *proc) { ProcArrayStruct *arrayP = procArray; int index; @@ -257,21 +253,6 @@ ProcArrayRemove(PGPROC *proc, TransactionId latestXid) LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); - if (TransactionIdIsValid(latestXid)) - { - Assert(TransactionIdIsValid(proc->xid)); - - /* Advance global latestCompletedXid while holding the lock */ - if (TransactionIdPrecedes(ShmemVariableCache->latestCompletedXid, - latestXid)) - ShmemVariableCache->latestCompletedXid = latestXid; - } - else - { - /* Shouldn't be trying to remove a live transaction here */ - Assert(!TransactionIdIsValid(proc->xid)); - } - for (index = 0; index < arrayP->numProcs; index++) { if (arrayP->procs[index] == proc) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 22cb0b8283..aa00bf5035 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -669,7 +669,7 @@ static void RemoveProcFromArray(int code, Datum arg) { Assert(MyProc != NULL); - ProcArrayRemove(MyProc, InvalidTransactionId); + ProcArrayRemove(MyProc); } /* diff --git a/src/include/storage/procarray.h b/src/include/storage/procarray.h index ee87e83479..072bd2b5a7 100644 --- a/src/include/storage/procarray.h +++ b/src/include/storage/procarray.h @@ -21,7 +21,7 @@ extern Size ProcArrayShmemSize(void); extern void CreateSharedProcArray(void); extern void ProcArrayAdd(PGPROC *proc); -extern void ProcArrayRemove(PGPROC *proc, TransactionId latestXid); +extern void ProcArrayRemove(PGPROC *proc); extern void ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid); extern void ProcArrayClearTransaction(PGPROC *proc); -- 2.39.5