Skip to content

Commit f66e7ab

Browse files
Clarify docs on hot standby lock release
Andres Freund and Simon Riggs
1 parent 8805ff6 commit f66e7ab

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/backend/storage/ipc/procarray.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,11 @@ ProcArrayInstallImportedXmin(TransactionId xmin, TransactionId sourcexid)
15651565
* We don't worry about updating other counters, we want to keep this as
15661566
* simple as possible and leave GetSnapshotData() as the primary code for
15671567
* that bookkeeping.
1568+
*
1569+
* Note that if any transaction has overflowed its cached subtransactions
1570+
* then there is no real need include any subtransactions. That isn't a
1571+
* common enough case to worry about optimising the size of the WAL record,
1572+
* and we may wish to see that data for diagnostic purposes anyway.
15681573
*/
15691574
RunningTransactions
15701575
GetRunningTransactionData(void)

src/backend/storage/ipc/standby.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,10 @@ CheckRecoveryConflictDeadlock(void)
510510
* RelationLockList, so we can keep track of the various entries made by
511511
* the Startup process's virtual xid in the shared lock table.
512512
*
513+
* We record the lock against the top-level xid, rather than individual
514+
* subtransaction xids. This means AccessExclusiveLocks held by aborted
515+
* subtransactions are not released as early as possible on standbys.
516+
*
513517
* List elements use type xl_rel_lock, since the WAL record type exactly
514518
* matches the information that we need to keep track of.
515519
*
@@ -643,8 +647,8 @@ StandbyReleaseAllLocks(void)
643647

644648
/*
645649
* StandbyReleaseOldLocks
646-
* Release standby locks held by XIDs that aren't running, as long
647-
* as they're not prepared transactions.
650+
* Release standby locks held by top-level XIDs that aren't running,
651+
* as long as they're not prepared transactions.
648652
*/
649653
void
650654
StandbyReleaseOldLocks(int nxids, TransactionId *xids)

0 commit comments

Comments
 (0)