Skip to content

Commit 802bde8

Browse files
Remove cut-off bug from RunningTransactionData
32ac7a1 tried to fix a Hot Standby issue reported by Greg Stark, but in doing so caused a different bug to appear, noted by Andres Freund. Revoke the core changes from 32ac7a1, leaving in its place a minor change in code ordering and comments to explain for the future.
1 parent 9178133 commit 802bde8

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/backend/storage/ipc/procarray.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,7 +1907,7 @@ ProcArrayInstallRestoredXmin(TransactionId xmin, PGPROC *proc)
19071907
* GetRunningTransactionData -- returns information about running transactions.
19081908
*
19091909
* Similar to GetSnapshotData but returns more information. We include
1910-
* all PGXACTs with an assigned TransactionId, but not VACUUM processes.
1910+
* all PGXACTs with an assigned TransactionId, even VACUUM processes.
19111911
*
19121912
* We acquire XidGenLock and ProcArrayLock, but the caller is responsible for
19131913
* releasing them. Acquiring XidGenLock ensures that no new XIDs enter the proc
@@ -1995,10 +1995,6 @@ GetRunningTransactionData(void)
19951995
volatile PGXACT *pgxact = &allPgXact[pgprocno];
19961996
TransactionId xid;
19971997

1998-
/* Ignore procs running LAZY VACUUM */
1999-
if (pgxact->vacuumFlags & PROC_IN_VACUUM)
2000-
continue;
2001-
20021998
/* Fetch xid just once - see GetNewTransactionId */
20031999
xid = pgxact->xid;
20042000

@@ -2009,13 +2005,26 @@ GetRunningTransactionData(void)
20092005
if (!TransactionIdIsValid(xid))
20102006
continue;
20112007

2012-
xids[count++] = xid;
2013-
2008+
/*
2009+
* Be careful not to exclude any xids before calculating the values of
2010+
* oldestRunningXid and suboverflowed, since these are used to clean
2011+
* up transaction information held on standbys.
2012+
*/
20142013
if (TransactionIdPrecedes(xid, oldestRunningXid))
20152014
oldestRunningXid = xid;
20162015

20172016
if (pgxact->overflowed)
20182017
suboverflowed = true;
2018+
2019+
/*
2020+
* If we wished to exclude xids this would be the right place for it.
2021+
* Procs with the PROC_IN_VACUUM flag set don't usually assign xids,
2022+
* but they do during truncation at the end when they get the lock
2023+
* and truncate, so it is not much of a problem to include them if they
2024+
* are seen and it is cleaner to include them.
2025+
*/
2026+
2027+
xids[count++] = xid;
20192028
}
20202029

20212030
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy