From 2bdadce8fdd5eb9466a8ded625f9c23939131a15 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 14 Oct 2011 15:28:56 -0400 Subject: [PATCH] Don't take ProcArrayLock when committing. --- src/backend/storage/ipc/procarray.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index 2fe19d292b..695e3bb33b 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -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, -- 2.39.5