Simplify ProcArrayRemove().
authorRobert Haas <rhaas@postgresql.org>
Sat, 15 Oct 2011 10:57:18 +0000 (06:57 -0400)
committerRobert Haas <rhaas@postgresql.org>
Sat, 15 Oct 2011 10:57:18 +0000 (06:57 -0400)
src/backend/access/transam/twophase.c
src/backend/storage/ipc/procarray.c
src/backend/storage/lmgr/proc.c
src/include/storage/procarray.h

index 058ea192627d6db4c0eea28ab5a96c3a62616b1c..4505918ef6596d845f76b44c95f4725a5c3c8d64 100644 (file)
@@ -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);
 
        /*
index 695e3bb33b4e15aed62843eebeb7a94e1ead4c7c..5145e5b054f1144741cb225a4b068c90bb9721e3 100644 (file)
@@ -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)
index 22cb0b82837e70ad4cb6a98b1a0dcec33a1ba0cf..aa00bf5035bf747442e7f7cec29060d440f0715d 100644 (file)
@@ -669,7 +669,7 @@ static void
 RemoveProcFromArray(int code, Datum arg)
 {
        Assert(MyProc != NULL);
-       ProcArrayRemove(MyProc, InvalidTransactionId);
+       ProcArrayRemove(MyProc);
 }
 
 /*
index ee87e8347947a7a3aa8c280b4d1d724069426472..072bd2b5a7186e8ae60d8b4acfa49757eade7c21 100644 (file)
@@ -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);