Skip to content

Commit 3dfaea4

Browse files
committed
Revert back-branch changes in behavior of age(xid).
Per discussion, it does not seem like a good idea to change the behavior of age(xid) in a minor release, even though the old definition causes the function to fail on hot standby slaves. Therefore, revert commit 5829387 and follow-on commits in the back branches only.
1 parent 56901be commit 3dfaea4

File tree

3 files changed

+2
-27
lines changed

3 files changed

+2
-27
lines changed

src/backend/access/transam/xact.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -392,30 +392,6 @@ GetCurrentTransactionIdIfAny(void)
392392
return CurrentTransactionState->transactionId;
393393
}
394394

395-
/*
396-
* GetStableLatestTransactionId
397-
*
398-
* Get the XID once and then return same value for rest of transaction.
399-
* Acts as a useful reference point for maintenance tasks.
400-
*/
401-
TransactionId
402-
GetStableLatestTransactionId(void)
403-
{
404-
static LocalTransactionId lxid = InvalidLocalTransactionId;
405-
static TransactionId stablexid = InvalidTransactionId;
406-
407-
if (lxid != MyProc->lxid)
408-
{
409-
lxid = MyProc->lxid;
410-
stablexid = GetTopTransactionIdIfAny();
411-
if (!TransactionIdIsValid(stablexid))
412-
stablexid = ReadNewTransactionId();
413-
}
414-
415-
Assert(TransactionIdIsValid(stablexid));
416-
417-
return stablexid;
418-
}
419395

420396
/*
421397
* AssignTransactionId

src/backend/utils/adt/xid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ xideq(PG_FUNCTION_ARGS)
8787
}
8888

8989
/*
90-
* xid_age - compute age of an XID (relative to latest stable xid)
90+
* xid_age - compute age of an XID (relative to current xact)
9191
*/
9292
Datum
9393
xid_age(PG_FUNCTION_ARGS)
9494
{
9595
TransactionId xid = PG_GETARG_TRANSACTIONID(0);
96-
TransactionId now = GetStableLatestTransactionId();
96+
TransactionId now = GetTopTransactionId();
9797

9898
/* Permanent XIDs are always infinitely old */
9999
if (!TransactionIdIsNormal(xid))

src/include/access/xact.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ extern TransactionId GetTopTransactionId(void);
198198
extern TransactionId GetTopTransactionIdIfAny(void);
199199
extern TransactionId GetCurrentTransactionId(void);
200200
extern TransactionId GetCurrentTransactionIdIfAny(void);
201-
extern TransactionId GetStableLatestTransactionId(void);
202201
extern SubTransactionId GetCurrentSubTransactionId(void);
203202
extern CommandId GetCurrentCommandId(bool used);
204203
extern TimestampTz GetCurrentTransactionStartTimestamp(void);

0 commit comments

Comments
 (0)