Skip to content

Commit 759340c

Browse files
Clarify docs on hot standby lock release
Andres Freund and Simon Riggs
1 parent bb745dc commit 759340c

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
@@ -1394,6 +1394,11 @@ GetSnapshotData(Snapshot snapshot)
13941394
* We don't worry about updating other counters, we want to keep this as
13951395
* simple as possible and leave GetSnapshotData() as the primary code for
13961396
* that bookkeeping.
1397+
*
1398+
* Note that if any transaction has overflowed its cached subtransactions
1399+
* then there is no real need include any subtransactions. That isn't a
1400+
* common enough case to worry about optimising the size of the WAL record,
1401+
* and we may wish to see that data for diagnostic purposes anyway.
13971402
*/
13981403
RunningTransactions
13991404
GetRunningTransactionData(void)

src/backend/storage/ipc/standby.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,10 @@ CheckRecoveryConflictDeadlock(void)
513513
* RelationLockList, so we can keep track of the various entries made by
514514
* the Startup process's virtual xid in the shared lock table.
515515
*
516+
* We record the lock against the top-level xid, rather than individual
517+
* subtransaction xids. This means AccessExclusiveLocks held by aborted
518+
* subtransactions are not released as early as possible on standbys.
519+
*
516520
* List elements use type xl_rel_lock, since the WAL record type exactly
517521
* matches the information that we need to keep track of.
518522
*
@@ -646,8 +650,8 @@ StandbyReleaseAllLocks(void)
646650

647651
/*
648652
* StandbyReleaseOldLocks
649-
* Release standby locks held by XIDs that aren't running, as long
650-
* as they're not prepared transactions.
653+
* Release standby locks held by top-level XIDs that aren't running,
654+
* as long as they're not prepared transactions.
651655
*/
652656
void
653657
StandbyReleaseOldLocks(int nxids, TransactionId *xids)

0 commit comments

Comments
 (0)