From: Simon Riggs Date: Mon, 5 Oct 2009 14:13:37 +0000 (+0100) Subject: Apply 0014-Make-locking-of-ShmemVariableCache-nextXid-in-multix.patch X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=48337207244784924fb4408f66fd15207b63dde8;p=users%2Fsimon%2Fpostgres.git Apply 0014-Make-locking-of-ShmemVariableCache-nextXid-in-multix.patch --- 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