diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-05-19 21:35:48 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-05-19 21:35:48 +0000 |
commit | ee3b71f6bce929b07636f76d1654832cb6b5a489 (patch) | |
tree | ce95108d3c0e832555b78e96afb173458991b19e /src/backend/access/transam/xact.c | |
parent | 6910032a56dd3841be137b4bef7c57ef32a60ac8 (diff) | |
download | postgresql-ee3b71f6bce929b07636f76d1654832cb6b5a489.tar.gz postgresql-ee3b71f6bce929b07636f76d1654832cb6b5a489.zip |
Split the shared-memory array of PGPROC pointers out of the sinval
communication structure, and make it its own module with its own lock.
This should reduce contention at least a little, and it definitely makes
the code seem cleaner. Per my recent proposal.
Diffstat (limited to 'src/backend/access/transam/xact.c')
-rw-r--r-- | src/backend/access/transam/xact.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index a318db61343..81fba82b489 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.200 2005/04/28 21:47:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.201 2005/05/19 21:35:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -34,7 +34,7 @@ #include "miscadmin.h" #include "storage/fd.h" #include "storage/proc.h" -#include "storage/sinval.h" +#include "storage/procarray.h" #include "storage/smgr.h" #include "utils/flatfiles.h" #include "utils/guc.h" @@ -1503,16 +1503,18 @@ CommitTransaction(void) * this must be done _before_ releasing locks we hold and _after_ * RecordTransactionCommit. * - * LWLockAcquire(SInvalLock) is required: UPDATE with xid 0 is blocked by - * xid 1' UPDATE, xid 1 is doing commit while xid 2 gets snapshot - if - * xid 2' GetSnapshotData sees xid 1 as running then it must see xid 0 - * as running as well or it will see two tuple versions - one deleted - * by xid 1 and one inserted by xid 0. See notes in GetSnapshotData. + * LWLockAcquire(ProcArrayLock) is required; consider this example: + * UPDATE with xid 0 is blocked by xid 1's UPDATE. + * xid 1 is doing commit while xid 2 gets snapshot. + * If xid 2's GetSnapshotData sees xid 1 as running then it must see + * xid 0 as running as well, or it will be able to see two tuple versions + * - one deleted by xid 1 and one inserted by xid 0. See notes in + * GetSnapshotData. */ if (MyProc != NULL) { - /* Lock SInvalLock because that's what GetSnapshotData uses. */ - LWLockAcquire(SInvalLock, LW_EXCLUSIVE); + /* Lock ProcArrayLock because that's what GetSnapshotData uses. */ + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); MyProc->xid = InvalidTransactionId; MyProc->xmin = InvalidTransactionId; @@ -1520,7 +1522,7 @@ CommitTransaction(void) MyProc->subxids.nxids = 0; MyProc->subxids.overflowed = false; - LWLockRelease(SInvalLock); + LWLockRelease(ProcArrayLock); } /* @@ -1688,8 +1690,8 @@ AbortTransaction(void) */ if (MyProc != NULL) { - /* Lock SInvalLock because that's what GetSnapshotData uses. */ - LWLockAcquire(SInvalLock, LW_EXCLUSIVE); + /* Lock ProcArrayLock because that's what GetSnapshotData uses. */ + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); MyProc->xid = InvalidTransactionId; MyProc->xmin = InvalidTransactionId; @@ -1697,7 +1699,7 @@ AbortTransaction(void) MyProc->subxids.nxids = 0; MyProc->subxids.overflowed = false; - LWLockRelease(SInvalLock); + LWLockRelease(ProcArrayLock); } /* |