diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-09-08 20:31:15 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-09-08 20:31:15 +0000 |
commit | 6bd4f401b0cb85f2e81caffc457e415e15e2ed5d (patch) | |
tree | a0edebb698a1a288be3e66c064c36399cbf5f93f /src/backend/utils/time/tqual.c | |
parent | 0a51e7073c045b5fce50092dae19f398f7b38e16 (diff) | |
download | postgresql-6bd4f401b0cb85f2e81caffc457e415e15e2ed5d.tar.gz postgresql-6bd4f401b0cb85f2e81caffc457e415e15e2ed5d.zip |
Replace the former method of determining snapshot xmax --- to wit, calling
ReadNewTransactionId from GetSnapshotData --- with a "latestCompletedXid"
variable that is updated during transaction commit or abort. Since
latestCompletedXid is written only in places that had to lock ProcArrayLock
exclusively anyway, and is read only in places that had to lock ProcArrayLock
shared anyway, it adds no new locking requirements to the system despite being
cluster-wide. Moreover, removing ReadNewTransactionId from snapshot
acquisition eliminates the need to take both XidGenLock and ProcArrayLock at
the same time. Since XidGenLock is sometimes held across I/O this can be a
significant win. Some preliminary benchmarking suggested that this patch has
no effect on average throughput but can significantly improve the worst-case
transaction times seen in pgbench. Concept by Florian Pflug, implementation
by Tom Lane.
Diffstat (limited to 'src/backend/utils/time/tqual.c')
-rw-r--r-- | src/backend/utils/time/tqual.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index 907476ee1f1..f580c0b4612 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -31,7 +31,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.104 2007/08/14 17:35:18 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.105 2007/09/08 20:31:15 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -71,10 +71,14 @@ Snapshot LatestSnapshot = NULL; */ Snapshot ActiveSnapshot = NULL; -/* These are updated by GetSnapshotData: */ -TransactionId TransactionXmin = InvalidTransactionId; -TransactionId RecentXmin = InvalidTransactionId; -TransactionId RecentGlobalXmin = InvalidTransactionId; +/* + * These are updated by GetSnapshotData. We initialize them this way + * for the convenience of TransactionIdIsInProgress: even in bootstrap + * mode, we don't want it to say that BootstrapTransactionId is in progress. + */ +TransactionId TransactionXmin = FirstNormalTransactionId; +TransactionId RecentXmin = FirstNormalTransactionId; +TransactionId RecentGlobalXmin = FirstNormalTransactionId; /* local functions */ static bool XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot); |