Apply 0014-Make-locking-of-ShmemVariableCache-nextXid-in-multix.patch
authorSimon Riggs <[email protected]>
Mon, 5 Oct 2009 14:13:37 +0000 (15:13 +0100)
committerSimon Riggs <[email protected]>
Mon, 5 Oct 2009 14:13:37 +0000 (15:13 +0100)
src/backend/access/transam/multixact.c

index 6f86961b887eb00a860c9916fa9e180e7448f804..80affa962445a924c2d01a5bfa7bc1f7b906849c 100644 (file)
@@ -1927,11 +1927,18 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record)
                        if (TransactionIdPrecedes(max_xid, xids[i]))
                                max_xid = xids[i];
                }
+
+               /* We don't expect anyone else to modify nextXid, hence we
+                * don't need to hold a lock while checking this. We still acquire
+                * the lock to modify it, though.
+                */
                if (TransactionIdFollowsOrEquals(max_xid,
                                                                                 ShmemVariableCache->nextXid))
                {
+                       LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
                        ShmemVariableCache->nextXid = max_xid;
                        TransactionIdAdvance(ShmemVariableCache->nextXid);
+                       LWLockRelease(XidGenLock);
                }
        }
        else