mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Relax locking during GetCurrentVirtualXIDs(). Earlier improvements
to handling of btree delete records mean that all snapshot conflicts on standby now have a valid, useful latestRemovedXid. Our earlier approach using LW_EXCLUSIVE was useful when we didnt always have a valid value, though is no longer useful or necessary. Asserts added to code path to prove and ensure this is the case. This will reduce contention and improve performance of larger Hot Standby servers.
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/standby.c,v 1.16 2010/04/06 10:50:57 sriggs Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/standby.c,v 1.17 2010/04/21 19:08:14 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -246,6 +246,24 @@ ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid, RelFileNode
|
||||
{
|
||||
VirtualTransactionId *backends;
|
||||
|
||||
/*
|
||||
* If we get passed InvalidTransactionId then we are a little surprised,
|
||||
* but it is theoretically possible, so spit out a LOG message, but not
|
||||
* one that needs translating.
|
||||
*
|
||||
* We grab latestCompletedXid instead because this is the very latest
|
||||
* value it could ever be.
|
||||
*/
|
||||
if (!TransactionIdIsValid(latestRemovedXid))
|
||||
{
|
||||
elog(LOG, "Invalid latestRemovedXid reported, using latestCompletedXid instead");
|
||||
|
||||
LWLockAcquire(ProcArrayLock, LW_SHARED);
|
||||
latestRemovedXid = ShmemVariableCache->latestCompletedXid;
|
||||
LWLockRelease(ProcArrayLock);
|
||||
}
|
||||
Assert(TransactionIdIsValid(latestRemovedXid));
|
||||
|
||||
backends = GetConflictingVirtualXIDs(latestRemovedXid,
|
||||
node.dbNode);
|
||||
|
||||
|
Reference in New Issue
Block a user