mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
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.
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.280 2007/09/05 18:10:47 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.281 2007/09/08 20:31:14 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -5196,6 +5196,10 @@ StartupXLOG(void)
|
||||
XLogCtl->ckptXidEpoch = ControlFile->checkPointCopy.nextXidEpoch;
|
||||
XLogCtl->ckptXid = ControlFile->checkPointCopy.nextXid;
|
||||
|
||||
/* also initialize latestCompletedXid, to nextXid - 1 */
|
||||
ShmemVariableCache->latestCompletedXid = ShmemVariableCache->nextXid;
|
||||
TransactionIdRetreat(ShmemVariableCache->latestCompletedXid);
|
||||
|
||||
/* Start up the commit log and related stuff, too */
|
||||
StartupCLOG();
|
||||
StartupSUBTRANS(oldestActiveXID);
|
||||
|
Reference in New Issue
Block a user