From 48337207244784924fb4408f66fd15207b63dde8 Mon Sep 17 00:00:00 2001 From: Simon Riggs Date: Mon, 5 Oct 2009 15:13:37 +0100 Subject: [PATCH] Apply 0014-Make-locking-of-ShmemVariableCache-nextXid-in-multix.patch --- src/backend/access/transam/multixact.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index 6f86961b88..80affa9624 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -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 -- 2.39.5