Clean up ProcArrayEndTransaction().
authorRobert Haas <rhaas@postgresql.org>
Sat, 15 Oct 2011 11:10:13 +0000 (07:10 -0400)
committerRobert Haas <rhaas@postgresql.org>
Sat, 15 Oct 2011 11:10:13 +0000 (07:10 -0400)
src/backend/access/transam/xact.c
src/backend/storage/ipc/procarray.c
src/include/storage/procarray.h

index 9c1e072d150c0b74a6ef02178280b51394c778e5..fb40b801e2de81aedbc132d245b79dafb1c65337 100644 (file)
@@ -1853,9 +1853,9 @@ CommitTransaction(void)
         * must be done _before_ releasing locks we hold and _after_
         * RecordTransactionCommit.
         */
-       ProcArrayEndTransaction(MyProc, latestXid);
        if (TransactionIdIsNormal(xid))
                SnapArrayRemoveRunningXids(xid, nchildren, children, latestXid);
+       ProcArrayEndTransaction(MyProc);
 
        /*
         * This is all post-commit cleanup.  Note that if an error is raised here,
@@ -2285,9 +2285,9 @@ AbortTransaction(void)
         * must be done _before_ releasing locks we hold and _after_
         * RecordTransactionAbort.
         */
-       ProcArrayEndTransaction(MyProc, latestXid);
        if (TransactionIdIsNormal(xid))
                SnapArrayRemoveRunningXids(xid, nchildren, children, latestXid);
+       ProcArrayEndTransaction(MyProc);
 
        /*
         * Post-abort cleanup.  See notes in CommitTransaction() concerning
index 5145e5b054f1144741cb225a4b068c90bb9721e3..232c741ca72f06dd2f701679ce6526808aa4488a 100644 (file)
@@ -279,58 +279,23 @@ ProcArrayRemove(PGPROC *proc)
  * commit/abort must already be reported to WAL and pg_clog.
  *
  * proc is currently always MyProc, but we pass it explicitly for flexibility.
- * latestXid is the latest Xid among the transaction's main XID and
- * subtransactions, or InvalidTransactionId if it has no XID.  (We must ask
- * the caller to pass latestXid, instead of computing it from the PGPROC's
- * contents, because the subxid information in the PGPROC might be
- * incomplete.)
  */
 void
-ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid)
+ProcArrayEndTransaction(PGPROC *proc)
 {
-       /*
-        * XXX.  This code can be further simplified now that we no longer
-        * use the PGPROC->xid fields to derive a snapshot.
-        */
-
-       if (TransactionIdIsValid(latestXid))
-       {
-               Assert(TransactionIdIsValid(proc->xid));
-
-               proc->xid = InvalidTransactionId;
-               proc->lxid = InvalidLocalTransactionId;
-               proc->xmin = InvalidTransactionId;
-               /* must be cleared with xid/xmin: */
-               proc->vacuumFlags &= ~PROC_VACUUM_STATE_MASK;
-               proc->inCommit = false; /* be sure this is cleared in abort */
-               proc->recoveryConflictPending = false;
-
-               /* Clear the subtransaction-XID cache too while holding the lock */
-               proc->subxids.nxids = 0;
-               proc->subxids.overflowed = false;
-       }
-       else
-       {
-               /*
-                * If we have no XID, we don't need to lock, since we won't affect
-                * anyone else's calculation of a snapshot.  We might change their
-                * estimate of global xmin, but that's OK.
-                */
-               Assert(!TransactionIdIsValid(proc->xid));
-
-               proc->lxid = InvalidLocalTransactionId;
-               proc->xmin = InvalidTransactionId;
-               /* must be cleared with xid/xmin: */
-               proc->vacuumFlags &= ~PROC_VACUUM_STATE_MASK;
-               proc->inCommit = false; /* be sure this is cleared in abort */
-               proc->recoveryConflictPending = false;
+       proc->xid = InvalidTransactionId;
+       proc->lxid = InvalidLocalTransactionId;
+       proc->xmin = InvalidTransactionId;
+       /* must be cleared with xid/xmin: */
+       proc->vacuumFlags &= ~PROC_VACUUM_STATE_MASK;
+       proc->inCommit = false;                         /* be sure this is cleared in abort */
+       proc->recoveryConflictPending = false;
 
-               Assert(proc->subxids.nxids == 0);
-               Assert(proc->subxids.overflowed == false);
-       }
+       /* Clear the subtransaction-XID cache too while holding the lock */
+       proc->subxids.nxids = 0;
+       proc->subxids.overflowed = false;
 }
 
-
 /*
  * ProcArrayClearTransaction -- clear the transaction fields
  *
index 072bd2b5a7186e8ae60d8b4acfa49757eade7c21..eb5238f01f007ecaf37ec46da4ae1ff739c68c9c 100644 (file)
@@ -23,7 +23,7 @@ extern void CreateSharedProcArray(void);
 extern void ProcArrayAdd(PGPROC *proc);
 extern void ProcArrayRemove(PGPROC *proc);
 
-extern void ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid);
+extern void ProcArrayEndTransaction(PGPROC *proc);
 extern void ProcArrayClearTransaction(PGPROC *proc);
 
 extern void ProcArrayApplyRecoveryInfo(RunningTransactions running);