mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Resolve timing issue with logging locks for Hot Standby.
We log AccessExclusiveLocks for replay onto standby nodes, but because of timing issues on ProcArray it is possible to log a lock that is still held by a just committed transaction that is very soon to be removed. To avoid any timing issue we avoid applying locks made by transactions with InvalidXid. Simon Riggs, bug report Tom Lane, diagnosis Pavan Deolasee
This commit is contained in:
@@ -3190,8 +3190,18 @@ GetRunningTransactionLocks(int *nlocks)
|
||||
PGPROC *proc = proclock->tag.myProc;
|
||||
PGXACT *pgxact = &ProcGlobal->allPgXact[proc->pgprocno];
|
||||
LOCK *lock = proclock->tag.myLock;
|
||||
TransactionId xid = pgxact->xid;
|
||||
|
||||
accessExclusiveLocks[index].xid = pgxact->xid;
|
||||
/*
|
||||
* Don't record locks for transactions if we know they have already
|
||||
* issued their WAL record for commit but not yet released lock.
|
||||
* It is still possible that we see locks held by already complete
|
||||
* transactions, if they haven't yet zeroed their xids.
|
||||
*/
|
||||
if (!TransactionIdIsValid(xid))
|
||||
continue;
|
||||
|
||||
accessExclusiveLocks[index].xid = xid;
|
||||
accessExclusiveLocks[index].dbOid = lock->tag.locktag_field1;
|
||||
accessExclusiveLocks[index].relOid = lock->tag.locktag_field2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user