Don't take ProcArrayLock when committing.
authorRobert Haas <rhaas@postgresql.org>
Fri, 14 Oct 2011 19:28:56 +0000 (15:28 -0400)
committerRobert Haas <rhaas@postgresql.org>
Fri, 14 Oct 2011 19:28:56 +0000 (15:28 -0400)
src/backend/storage/ipc/procarray.c

index 2fe19d292bd9fcaf7ce541de0d26c8cfb9eb0f07..695e3bb33b4e15aed62843eebeb7a94e1ead4c7c 100644 (file)
@@ -307,18 +307,15 @@ ProcArrayRemove(PGPROC *proc, TransactionId latestXid)
 void
 ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid)
 {
+       /*
+        * XXX.  This code can be further simplified now that we no longer
+        * use the PGPROC->xid fields to derive a snapshot.
+        */
+
        if (TransactionIdIsValid(latestXid))
        {
-               /*
-                * We must lock ProcArrayLock while clearing proc->xid, so that we do
-                * not exit the set of "running" transactions while someone else is
-                * taking a snapshot.  See discussion in
-                * src/backend/access/transam/README.
-                */
                Assert(TransactionIdIsValid(proc->xid));
 
-               LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
-
                proc->xid = InvalidTransactionId;
                proc->lxid = InvalidLocalTransactionId;
                proc->xmin = InvalidTransactionId;
@@ -330,13 +327,6 @@ ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid)
                /* Clear the subtransaction-XID cache too while holding the lock */
                proc->subxids.nxids = 0;
                proc->subxids.overflowed = false;
-
-               /* Also advance global latestCompletedXid while holding the lock */
-               if (TransactionIdPrecedes(ShmemVariableCache->latestCompletedXid,
-                                                                 latestXid))
-                       ShmemVariableCache->latestCompletedXid = latestXid;
-
-               LWLockRelease(ProcArrayLock);
        }
        else
        {
@@ -1151,6 +1141,8 @@ IsBackendPid(int pid)
  * any snapshot the other backend is taking concurrently with our scan cannot
  * consider any transactions as still running that we think are committed
  * (since backends must hold ProcArrayLock exclusive to commit).
+ *
+ * XXX: I think this is probably broken by the SnapArray stuff.
  */
 VirtualTransactionId *
 GetCurrentVirtualXIDs(TransactionId limitXmin, bool excludeXmin0,