Make some changes to code and comments in KnownAssignedXids functions. Based upon...
authorSimon Riggs <simon@2ndQuadrant.com>
Mon, 5 Oct 2009 13:17:20 +0000 (14:17 +0100)
committerSimon Riggs <simon@2ndQuadrant.com>
Mon, 5 Oct 2009 13:17:20 +0000 (14:17 +0100)
src/backend/storage/ipc/procarray.c

index c9e010ed15fb5c53394fc656ef38e61bd1e20d07..7d1f42ce29a1dea4f3b5374202e13bda6566fbb4 100644 (file)
@@ -513,6 +513,11 @@ ProcArrayApplyRecoveryInfo(XLogRecPtr lsn, xl_xact_running_xacts *xlrec)
        xids = palloc(sizeof(TransactionId) * (xlrec->xcnt + xlrec->subxcnt));
        nxids = 0;
 
+       /*
+        * Nobody else is running yet, but take locks anyhow
+        */
+       LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
+
        ProcArrayDisplay(trace_recovery(DEBUG3));
 
        /*
@@ -536,11 +541,6 @@ ProcArrayApplyRecoveryInfo(XLogRecPtr lsn, xl_xact_running_xacts *xlrec)
 
        }
 
-       /*
-        * Nobody else is running yet, but take locks anyhow
-        */
-       LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
-
        if (TransactionIdPrecedes(ShmemVariableCache->latestCompletedXid,
                                                          xlrec->latestCompletedXid))
                ShmemVariableCache->latestCompletedXid = xlrec->latestCompletedXid;
@@ -2532,7 +2532,7 @@ KnownAssignedXidsGet(TransactionId *xarray, TransactionId *xmin,
  * Prune KnownAssignedXids up to, but *not* including xid. If xid is invalid
  * then clear the whole table.
  * 
- * Must be called while not holding ProcArrayLock. Will grab lock if required.
+ * Must be called while holding ProcArrayLock in Exclusive mode.
  */
 static void
 KnownAssignedXidsRemoveMany(TransactionId xid)
@@ -2595,7 +2595,7 @@ xidComparator(const void *arg1, const void *arg2)
 /*
  * Display KnownAssignedXids to provide debug trail
  * 
- * Must be called while holding ProcArrayLock in Exclusive mode
+ * Must be called while holding ProcArrayLock in Shared mode
  */
 void
 KnownAssignedXidsDisplay(int trace_level)